Close #19282: Native context management in dbm

This commit is contained in:
Nick Coghlan 2013-11-17 15:59:51 +10:00
parent eb8ea265ba
commit c610aba1ed
8 changed files with 101 additions and 16 deletions

View file

@ -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.