mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix #11491. When dbm.open was called with a file which already exists and
the "flag" argument is "n", dbm.error was being raised. As documented, dbm.open(...,flag='n') will now "Always create a new, empty database, open for reading and writing", regardless of a previous file existing.
This commit is contained in:
parent
d9a7c4b8e5
commit
525c25d42f
4 changed files with 16 additions and 3 deletions
|
@ -70,6 +70,14 @@ class AnyDBMTestCase(unittest.TestCase):
|
|||
self.read_helper(f)
|
||||
f.close()
|
||||
|
||||
def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
|
||||
with open(_fname, "w") as w:
|
||||
pass # create an empty file
|
||||
|
||||
f = dbm.open(_fname, 'n')
|
||||
self.addCleanup(f.close)
|
||||
self.assertEqual(len(f), 0)
|
||||
|
||||
def test_anydbm_modification(self):
|
||||
self.init_db()
|
||||
f = dbm.open(_fname, 'c')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue