Issue33106
Created on 2018-03-19 21:44 by sam-s, last changed 2018-12-12 13:05 by xiang.zhang. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 6295 | merged | xiang.zhang, 2018-03-28 15:51 | |
| Messages (5) | |||
|---|---|---|---|
| msg314119 - (view) | Author: sds (sam-s) | Date: 2018-03-19 21:44 | |
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
|
|||
| msg314120 - (view) | Author: sds (sam-s) | Date: 2018-03-19 21:49 | |
Same problem with 3.6.4, start with >>> from dbm import gnu as gdbm then the same incorrect behavior |
|||
| msg314603 - (view) | Author: Xiang Zhang (xiang.zhang) * | Date: 2018-03-28 15:02 | |
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? |
|||
| msg319062 - (view) | Author: sds (sam-s) | Date: 2018-06-08 13:34 | |
I think consistency would be nice -- so, yes, `dbm.dumb.error` instead of `ValueError` (or at least a subtype of `dbm.dumb.error`). Thanks! |
|||
| msg331694 - (view) | Author: Xiang Zhang (xiang.zhang) * | Date: 2018-12-12 12:46 | |
New changeset 4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 by Xiang Zhang in branch 'master': bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295) https://github.com/python/cpython/commit/4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-12-12 13:05:50 | xiang.zhang | set | status: open -> closed type: behavior -> enhancement resolution: fixed stage: patch review -> resolved |
| 2018-12-12 12:46:58 | xiang.zhang | set | messages: + msg331694 |
| 2018-06-08 13:34:19 | sam-s | set | messages: + msg319062 |
| 2018-03-28 15:51:39 | xiang.zhang | set | keywords:
+ patch stage: patch review pull_requests: + pull_request6019 |
| 2018-03-28 15:02:48 | xiang.zhang | set | nosy:
+ xiang.zhang messages:
+ msg314603 |
| 2018-03-19 21:49:04 | sam-s | set | messages:
+ msg314120 versions: + Python 3.6, - Python 2.7 |
| 2018-03-19 21:44:11 | sam-s | create | |