summaryrefslogtreecommitdiffstats
path: root/Modules/_gdbmmodule.c
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2018-12-12 12:46:55 (GMT)
committerGitHub <noreply@github.com>2018-12-12 12:46:55 (GMT)
commit4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53 (patch)
treeaa3b18ad394fbd5056af5a366e2b4ca6b91d5296 /Modules/_gdbmmodule.c
parent5a718e918db6211b633a7afb2bf537eb5b56cb1b (diff)
downloadcpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.zip
cpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.tar.gz
cpython-4fb0b8bc25c52aae8dcb4353e69c1c88999a9a53.tar.bz2
bpo-33106: change dbm key deletion error for readonly file from KeyError to dbm.error (#6295)
Diffstat (limited to 'Modules/_gdbmmodule.c')
-rw-r--r--Modules/_gdbmmodule.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c
index 46bb59a..cc94e60 100644
--- a/Modules/_gdbmmodule.c
+++ b/Modules/_gdbmmodule.c
@@ -186,14 +186,19 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
dp->di_size = -1;
if (w == NULL) {
if (gdbm_delete(dp->di_dbm, krec) < 0) {
- PyErr_SetObject(PyExc_KeyError, v);
+ if (gdbm_errno == GDBM_ITEM_NOT_FOUND) {
+ PyErr_SetObject(PyExc_KeyError, v);
+ }
+ else {
+ PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno));
+ }
return -1;
}
}
else {
if (!PyArg_Parse(w, "s#", &drec.dptr, &drec.dsize)) {
PyErr_SetString(PyExc_TypeError,
- "gdbm mappings have byte or string elements only");
+ "gdbm mappings have bytes or string elements only");
return -1;
}
errno = 0;