summaryrefslogtreecommitdiffstats
path: root/Lib/dbm/dumb.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-02-04 15:23:26 (GMT)
committerGitHub <noreply@github.com>2024-02-04 15:23:26 (GMT)
commitfc060969117f5a5dc96c220eb91b1e2f863d71cf (patch)
tree98b221abc21b5203b90cc725b719ae571fd0f4a8 /Lib/dbm/dumb.py
parentff7588b729a2a414ea189a2012904da3fbd1401c (diff)
downloadcpython-fc060969117f5a5dc96c220eb91b1e2f863d71cf.zip
cpython-fc060969117f5a5dc96c220eb91b1e2f863d71cf.tar.gz
cpython-fc060969117f5a5dc96c220eb91b1e2f863d71cf.tar.bz2
gh-83383: Always mark the dbm.dumb database as unmodified after open() and sync() (GH-114560)
The directory file for a newly created database is now created immediately after opening instead of deferring this until synchronizing or closing.
Diffstat (limited to 'Lib/dbm/dumb.py')
-rw-r--r--Lib/dbm/dumb.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/dbm/dumb.py b/Lib/dbm/dumb.py
index 754624c..def120f 100644
--- a/Lib/dbm/dumb.py
+++ b/Lib/dbm/dumb.py
@@ -98,7 +98,8 @@ class _Database(collections.abc.MutableMapping):
except OSError:
if flag not in ('c', 'n'):
raise
- self._modified = True
+ with self._io.open(self._dirfile, 'w', encoding="Latin-1") as f:
+ self._chmod(self._dirfile)
else:
with f:
for line in f:
@@ -134,6 +135,7 @@ class _Database(collections.abc.MutableMapping):
# position; UTF-8, though, does care sometimes.
entry = "%r, %r\n" % (key.decode('Latin-1'), pos_and_siz_pair)
f.write(entry)
+ self._modified = False
sync = _commit