semidbm
semidbm copied to clipboard
Deleting a nonexistent key corrupts the database
>>> import semidbm
>>> db = semidbm.open('test', 'n')
>>> del db[b'nonexistent']
Traceback [...]
KeyError: b'nonexistent'
>>> db[b'foo'] = b'bar'
>>> db[b'foo']
b'exi'
>>> db.close()
>>> db = semidbm.open('test', 'r')
Traceback [...]
KeyError: b'nonexistent'
The fix is probably to move the del
above the write
in _SemiDBM.__delitem__
(and add a regression test).