summaryrefslogtreecommitdiffstats
path: root/Objects/namespaceobject.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 /Objects/namespaceobject.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 'Objects/namespaceobject.c')
-rw-r--r--Objects/namespaceobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c
index 2acf809..aba3ff7 100644
--- a/Objects/namespaceobject.c
+++ b/Objects/namespaceobject.c
@@ -102,9 +102,9 @@ namespace_repr(PyObject *ns)
if (PyUnicode_Check(key) && PyUnicode_GET_LENGTH(key) > 0) {
PyObject *value, *item;
- value = PyDict_GetItem(d, key);
+ value = PyDict_GetItemWithError(d, key);
if (value != NULL) {
- item = PyUnicode_FromFormat("%S=%R", key, value);
+ item = PyUnicode_FromFormat("%U=%R", key, value);
if (item == NULL) {
loop_error = 1;
}
@@ -113,6 +113,9 @@ namespace_repr(PyObject *ns)
Py_DECREF(item);
}
}
+ else if (PyErr_Occurred()) {
+ loop_error = 1;
+ }
}
Py_DECREF(key);