gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)

This commit is contained in:
Serhiy Storchaka 2023-07-12 08:57:10 +03:00 committed by GitHub
parent e8ab0096a5
commit be1b968dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 351 additions and 352 deletions

View file

@ -34,7 +34,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs)
}
continue;
}
if (_PyObject_LookupAttr(base, &_Py_ID(__mro_entries__), &meth) < 0) {
if (PyObject_GetOptionalAttr(base, &_Py_ID(__mro_entries__), &meth) < 0) {
goto error;
}
if (!meth) {
@ -175,7 +175,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
}
/* else: meta is not a class, so we cannot do the metaclass
calculation, so we will use the explicitly given object as it is */
if (_PyObject_LookupAttr(meta, &_Py_ID(__prepare__), &prep) < 0) {
if (PyObject_GetOptionalAttr(meta, &_Py_ID(__prepare__), &prep) < 0) {
ns = NULL;
}
else if (prep == NULL) {
@ -1160,7 +1160,7 @@ builtin_getattr_impl(PyObject *module, PyObject *object, PyObject *name,
PyObject *result;
if (default_value != NULL) {
if (_PyObject_LookupAttr(object, name, &result) == 0) {
if (PyObject_GetOptionalAttr(object, name, &result) == 0) {
return Py_NewRef(default_value);
}
}
@ -1209,7 +1209,7 @@ builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name)
{
PyObject *v;
if (_PyObject_LookupAttr(obj, name, &v) < 0) {
if (PyObject_GetOptionalAttr(obj, name, &v) < 0) {
return NULL;
}
if (v == NULL) {
@ -2465,7 +2465,7 @@ builtin_vars_impl(PyObject *module, PyObject *object)
d = _PyEval_GetFrameLocals();
}
else {
if (_PyObject_LookupAttr(object, &_Py_ID(__dict__), &d) == 0) {
if (PyObject_GetOptionalAttr(object, &_Py_ID(__dict__), &d) == 0) {
PyErr_SetString(PyExc_TypeError,
"vars() argument must have __dict__ attribute");
}