summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-01 11:01:05 (GMT)
committerGitHub <noreply@github.com>2019-09-01 11:01:05 (GMT)
commit353053d9ad08fea0e205e6c008b8a4350c0188e6 (patch)
tree3bd4434c152e934fb260c1c1651c080c3df29a14 /Python/bltinmodule.c
parent6922b9e4fce635339cb94c2fdef6bba4e2a99621 (diff)
downloadcpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.zip
cpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.tar.gz
cpython-353053d9ad08fea0e205e6c008b8a4350c0188e6.tar.bz2
[3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630) (GH-15635)
Only AttributeError should be silenced. (cherry picked from commit 41c57b335330ff48af098d47e379e0f9ba09d233)
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 b85bfb2..8f9e813 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2256,16 +2256,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;