Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue33106

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Deleting a key in a read-only gdbm results in KeyError, not gdbm.error
Type:enhancementStage:resolved
Components:Library (Lib)Versions:Python 3.8
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: sam-s, xiang.zhang
Priority:normalKeywords:patch

Created on2018-03-19 21:44 bysam-s, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 6295mergedxiang.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 gdbmthen 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 changeset4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 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
DateUserActionArgs
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
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp