dbm.gnu and dbm.ndbm accept both strings and bytes as keys and values. For the

former they are converted to bytes before being written to the DB.

Closes issue 3799. Reviewed by Skip Montanaro.
This commit is contained in:
Brett Cannon 2008-11-25 19:19:17 +00:00
parent 50d5a1c373
commit 7317c1ef7a
7 changed files with 40 additions and 19 deletions

View file

@ -20,9 +20,11 @@ def test_key_methods(self):
self.assertEqual(self.g.keys(), [])
self.g['a'] = 'b'
self.g['12345678910'] = '019237410982340912840198242'
self.g[b'bytes'] = b'data'
key_set = set(self.g.keys())
self.assertEqual(key_set, set([b'a', b'12345678910']))
self.assert_(b'a' in self.g)
self.assertEqual(self.g[b'bytes'], b'data')
key = self.g.firstkey()
while key:
self.assert_(key in key_set)