summaryrefslogtreecommitdiff
path: root/Python/bltinmodule.c
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
parentf02ea6225bc3b71bd5fe66224d199a6e3e23b14d (diff)
downloadcpython-git-41c57b335330ff48af098d47e379e0f9ba09d233.tar.gz
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 63e5812865..5053f7a174 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;