summaryrefslogtreecommitdiffstats
path: root/Lib/dbm/dumb.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-11-17 05:59:51 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-11-17 05:59:51 (GMT)
commitc610aba1ed57a30104a254ccd1f9fe07d02b1334 (patch)
treede690ad2f0b0f9cda831d66f026e5494a77882c5 /Lib/dbm/dumb.py
parenteb8ea265bac16844efebe4f42d3c674527a66988 (diff)
downloadcpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.zip
cpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.tar.gz
cpython-c610aba1ed57a30104a254ccd1f9fe07d02b1334.tar.bz2
Close #19282: Native context management in dbm
Diffstat (limited to 'Lib/dbm/dumb.py')
-rw-r--r--Lib/dbm/dumb.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/dbm/dumb.py b/Lib/dbm/dumb.py
index 9ac7852..ba6a20d 100644
--- a/Lib/dbm/dumb.py
+++ b/Lib/dbm/dumb.py
@@ -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.