diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 09:11:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-07 09:11:12 (GMT) |
commit | 4fc7942118f017c214534d29b18f2f844e68c8cf (patch) | |
tree | 96d01af875793a86f0c33cd3d08ff04d9e9586af /Lib/dbm/dumb.py | |
parent | 43153e4d49100b46a603afa8deeca415eb18d180 (diff) | |
download | cpython-4fc7942118f017c214534d29b18f2f844e68c8cf.zip cpython-4fc7942118f017c214534d29b18f2f844e68c8cf.tar.gz cpython-4fc7942118f017c214534d29b18f2f844e68c8cf.tar.bz2 |
Issue #28847: A deprecation warning is now emitted if the index file is missed
and recreated in the 'r' and 'w' modes (will be an error in future Python
releases).
Diffstat (limited to 'Lib/dbm/dumb.py')
-rw-r--r-- | Lib/dbm/dumb.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/dbm/dumb.py b/Lib/dbm/dumb.py index 2296dbf..c3c4a66 100644 --- a/Lib/dbm/dumb.py +++ b/Lib/dbm/dumb.py @@ -68,7 +68,7 @@ class _Database(collections.MutableMapping): # Handle the creation self._create(flag) - self._update() + self._update(flag) def _create(self, flag): if flag == 'n': @@ -92,12 +92,17 @@ class _Database(collections.MutableMapping): f.close() # Read directory file into the in-memory index dict. - def _update(self): + def _update(self, flag): self._index = {} try: f = _io.open(self._dirfile, 'r', encoding="Latin-1") except OSError: self._modified = not self._readonly + if flag not in ('c', 'n'): + import warnings + warnings.warn("The index file is missing, the " + "semantics of the 'c' flag will be used.", + DeprecationWarning, stacklevel=4) else: self._modified = False with f: |