cpython: 0a74bc7ba462 (original) (raw)

Mercurial > cpython

changeset 105501:0a74bc7ba462 3.5

Issue #28847: dbm.dumb now supports reading read-only files and no longer writes the index file when it is not changed. [#28847]

Serhiy Storchaka storchaka@gmail.com
date Wed, 07 Dec 2016 10:56:39 +0200
parents 104fdc42bcd1
children 0c532bd28539 1f31bf3f76f5
files Lib/dbm/dumb.py Lib/test/support/__init__.py Lib/test/test_dbm_dumb.py Misc/NEWS
diffstat 4 files changed, 28 insertions(+), 5 deletions(-)[+] [-] Lib/dbm/dumb.py 8 Lib/test/support/__init__.py 6 Lib/test/test_dbm_dumb.py 16 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/dbm/dumb.py +++ b/Lib/dbm/dumb.py @@ -47,6 +47,7 @@ class _Database(collections.MutableMappi def init(self, filebasename, mode, flag='c'): self._mode = mode

# The directory file is a text file. Each line looks like # "%r, (%d, %d)\n" % (key, pos, siz) @@ -91,8 +92,9 @@ class _Database(collections.MutableMappi try: f = _io.open(self._dirfile, 'r', encoding="Latin-1") except OSError:

@@ -107,7 +109,7 @@ class _Database(collections.MutableMappi # CAUTION: It's vital that _commit() succeed, and _commit() can # be called from del(). Therefore we must never reference a # global in this routine.

try: @@ -187,6 +189,7 @@ class _Database(collections.MutableMappi elif not isinstance(val, (bytes, bytearray)): raise TypeError("values must be bytes or strings") self._verify_open()

@@ -215,6 +218,7 @@ class _Database(collections.MutableMappi if isinstance(key, str): key = key.encode('utf-8') self._verify_open()

--- a/Lib/test/support/init.py +++ b/Lib/test/support/init.py @@ -359,9 +359,9 @@ if sys.platform.startswith("win"): mode = 0 if stat.S_ISDIR(mode): _waitfor(_rmtree_inner, fullname, waitall=True)

else: @@ -933,7 +933,7 @@ def temp_dir(path=None, quiet=False): yield path finally: if dir_created:

@contextlib.contextmanager def change_cwd(path, quiet=False):

--- a/Lib/test/test_dbm_dumb.py +++ b/Lib/test/test_dbm_dumb.py @@ -5,6 +5,7 @@ import io import operator import os +import stat import unittest import dbm.dumb as dumbdbm from test import support @@ -234,6 +235,21 @@ class DumbDBMTestCase(unittest.TestCase) pass self.assertEqual(stdout.getvalue(), '')

+ def tearDown(self): _delete_files()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -121,6 +121,9 @@ Core and Builtins Library ------- +- Issue #28847: dbm.dumb now supports reading read-only files and no longer