-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Deleting a key in a read-only gdbm results in KeyError, not gdbm.error #77287
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
Comments
deleting a key from a read-only gdbm should be gdbm.error, not KeyError: >>> import gdbm
>>> db = gdbm.open("foo","n") # create new
>>> db["a"] = "b"
>>> db.close()
>>> db = gdbm.open("foo","r") # read only
>>> db["x"] = "1"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
gdbm.error: Reader can't store # correct
>>> db["a"]
'b'
>>> del db["a"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'a' # WRONG! should be the same as above |
Same problem with 3.6.4, start with
then the same incorrect behavior |
I like this idea. But this is a behavior change so I think it could only be applied to master branch. But there is a problem, except dbm.gnu and dbm.ndbm, we also get dbm.dumb. It already raises a ValueError when deleting a key in readonly mode. Does it need to be changed to raise dbm.dumb.error to achieve consistency? |
I think consistency would be nice -- so, yes, |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: