This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2018-03-19 21:44 by sam-s, last changed 2022-04-11 14:58 by admin. 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) * (Python committer) 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) * (Python committer) 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
2022-04-11 14:58:58adminsetgithub: 77287
2018-12-12 13:05:50xiang.zhangsetstatus: open -> closed
type: behavior -> enhancement
resolution: fixed
stage: patch review -> resolved
2018-12-12 12:46:58xiang.zhangsetmessages: + msg331694
2018-06-08 13:34:19sam-ssetmessages: + msg319062
2018-03-28 15:51:39xiang.zhangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6019
2018-03-28 15:02:48xiang.zhangsetnosy: + xiang.zhang

messages: + msg314603
versions: + Python 3.8, - Python 3.6
2018-03-19 21:49:04sam-ssetmessages: + msg314120
versions: + Python 3.6, - Python 2.7
2018-03-19 21:44:11sam-screate