mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-33383: Fix crash in get() of the dbm.ndbm database object. (#6630)
This commit is contained in:
parent
5779483299
commit
2e38cc3933
7 changed files with 38 additions and 7 deletions
|
@ -86,12 +86,21 @@ class AnyDBMTestCase:
|
|||
f = dbm.open(_fname, 'c')
|
||||
self._dict['g'] = f[b'g'] = b"indented"
|
||||
self.read_helper(f)
|
||||
# setdefault() works as in the dict interface
|
||||
self.assertEqual(f.setdefault(b'xxx', b'foo'), b'foo')
|
||||
self.assertEqual(f[b'xxx'], b'foo')
|
||||
f.close()
|
||||
|
||||
def test_anydbm_read(self):
|
||||
self.init_db()
|
||||
f = dbm.open(_fname, 'r')
|
||||
self.read_helper(f)
|
||||
# get() works as in the dict interface
|
||||
self.assertEqual(f.get(b'a'), self._dict['a'])
|
||||
self.assertEqual(f.get(b'xxx', b'foo'), b'foo')
|
||||
self.assertIsNone(f.get(b'xxx'))
|
||||
with self.assertRaises(KeyError):
|
||||
f[b'xxx']
|
||||
f.close()
|
||||
|
||||
def test_anydbm_keys(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue