mirror of
https://github.com/python/cpython.git
synced 2025-09-23 00:43:12 +00:00
[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 41c57b3353
)
This commit is contained in:
parent
6922b9e4fc
commit
353053d9ad
14 changed files with 133 additions and 126 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue