Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a nonexistent key corrupts the database #23

Open
benrg opened this issue Jan 6, 2022 · 0 comments
Open

Deleting a nonexistent key corrupts the database #23

benrg opened this issue Jan 6, 2022 · 0 comments

Comments

@benrg
Copy link

benrg commented Jan 6, 2022

>>> 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant