mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Close #19282: Native context management in dbm
This commit is contained in:
parent
eb8ea265ba
commit
c610aba1ed
8 changed files with 101 additions and 16 deletions
|
@ -236,6 +236,12 @@ class _Database(collections.MutableMapping):
|
|||
if hasattr(self._os, 'chmod'):
|
||||
self._os.chmod(file, self._mode)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.close()
|
||||
|
||||
|
||||
def open(file, flag=None, mode=0o666):
|
||||
"""Open the database file, filename, and return corresponding object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue