diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-02-25 15:59:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 15:59:46 (GMT) |
commit | a24107b04c1277e3c1105f98aff5bfa3a98b33a0 (patch) | |
tree | 55aa5a700e08e3ba27b0361df2b1043be5c4701a /Objects/moduleobject.c | |
parent | a180b007d96fe68b32f11dec720fbd0cd5b6758a (diff) | |
download | cpython-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/moduleobject.c')
-rw-r--r-- | Objects/moduleobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index fca8521..9d65332 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -792,16 +792,17 @@ static PyObject * module_dir(PyObject *self, PyObject *args) { _Py_IDENTIFIER(__dict__); + _Py_IDENTIFIER(__dir__); PyObject *result = NULL; PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__); if (dict != NULL) { if (PyDict_Check(dict)) { - PyObject *dirfunc = PyDict_GetItemString(dict, "__dir__"); + PyObject *dirfunc = _PyDict_GetItemIdWithError(dict, &PyId___dir__); if (dirfunc) { result = _PyObject_CallNoArg(dirfunc); } - else { + else if (!PyErr_Occurred()) { result = PyDict_Keys(dict); } } |