summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 12:03:39 +0300
committerGitHub <noreply@github.com>2019-09-01 12:03:39 +0300
commit41c57b335330ff48af098d47e379e0f9ba09d233 (patch)
tree15cdef099182eddb04b2276dc51375b8faf28278 /Python/bltinmodule.c
parentbpo-36543: Remove old-deprecated ElementTree features. (GH-12707) (diff)
downloadcpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.gz
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.tar.bz2
cpython-41c57b335330ff48af098d47e379e0f9ba09d233.zip
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
Only AttributeError should be silenced.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 63e58128651..5053f7a1748 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2255,16 +2255,12 @@ builtin_vars(PyObject *self, PyObject *args)
return NULL;
if (v == NULL) {
d = PyEval_GetLocals();
- if (d == NULL)
- return NULL;
- Py_INCREF(d);
+ Py_XINCREF(d);
}
else {
- d = _PyObject_GetAttrId(v, &PyId___dict__);
- if (d == NULL) {
+ if (_PyObject_LookupAttrId(v, &PyId___dict__, &d) == 0) {
PyErr_SetString(PyExc_TypeError,
"vars() argument must have __dict__ attribute");
- return NULL;
}
}
return d;