bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)

Only AttributeError should be silenced.
This commit is contained in:
Serhiy Storchaka 2019-09-01 12:03:39 +03:00 committed by GitHub
parent f02ea6225b
commit 41c57b3353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 134 additions and 127 deletions

View file

@ -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;