summaryrefslogtreecommitdiffstats
path: root/Modules/xxmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-02-25 15:59:46 (GMT)
committerGitHub <noreply@github.com>2019-02-25 15:59:46 (GMT)
commita24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch)
tree55aa5a700e08e3ba27b0361df2b1043be5c4701a /Modules/xxmodule.c
parenta180b007d96fe68b32f11dec720fbd0cd5b6758a (diff)
downloadcpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.zip
cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.gz
cpython-a24107b04c1277e3c1105f98aff5bfa3a98b33a0.tar.bz2
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
Diffstat (limited to 'Modules/xxmodule.c')
-rw-r--r--Modules/xxmodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index c0564ea..d546901 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -66,11 +66,14 @@ static PyObject *
Xxo_getattro(XxoObject *self, PyObject *name)
{
if (self->x_attr != NULL) {
- PyObject *v = PyDict_GetItem(self->x_attr, name);
+ PyObject *v = PyDict_GetItemWithError(self->x_attr, name);
if (v != NULL) {
Py_INCREF(v);
return v;
}
+ else if (PyErr_Occurred()) {
+ return NULL;
+ }
}
return PyObject_GenericGetAttr((PyObject *)self, name);
}
@@ -85,7 +88,7 @@ Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
}
if (v == NULL) {
int rv = PyDict_DelItemString(self->x_attr, name);
- if (rv < 0)
+ if (rv < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
PyErr_SetString(PyExc_AttributeError,
"delete non-existing Xxo attribute");
return rv;