bpo-35444: Fix error handling when fail to look up builtin "getattr". (GH-11047) (GH-11107)

(cherry picked from commit bb86bf4c4e)
This commit is contained in:
Serhiy Storchaka 2018-12-11 10:51:27 +02:00 committed by GitHub
parent 62674f3a36
commit 3cae16d2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 30 deletions

View file

@ -4419,6 +4419,20 @@ PyEval_GetBuiltins(void)
return current_frame->f_builtins;
}
/* Convenience function to get a builtin from its name */
PyObject *
_PyEval_GetBuiltinId(_Py_Identifier *name)
{
PyObject *attr = _PyDict_GetItemIdWithError(PyEval_GetBuiltins(), name);
if (attr) {
Py_INCREF(attr);
}
else if (!PyErr_Occurred()) {
PyErr_SetObject(PyExc_AttributeError, _PyUnicode_FromId(name));
}
return attr;
}
PyObject *
PyEval_GetLocals(void)
{