]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-102213: Revert "gh-102213: Optimize the performance of `__getattr__` (GH-102248...
authorNikita Sobolev <mail@sobolevn.me>
Fri, 7 Apr 2023 09:22:36 +0000 (12:22 +0300)
committerGitHub <noreply@github.com>
Fri, 7 Apr 2023 09:22:36 +0000 (17:22 +0800)
This reverts commit aa0a73d1bc53dcb6348a869df1e775138991e561.

Include/internal/pycore_object.h
Objects/object.c
Objects/typeobject.c

index e18e787449c25776514ec6ac3ed144855ef235ad..b3d496ed6fc240c020f9513578c5ed4e5ba6e3e3 100644 (file)
@@ -375,7 +375,6 @@ extern void _PyObject_FreeInstanceAttributes(PyObject *obj);
 extern int _PyObject_IsInstanceDictEmpty(PyObject *);
 extern int _PyType_HasSubclasses(PyTypeObject *);
 extern PyObject* _PyType_GetSubclasses(PyTypeObject *);
-extern PyObject* _PyObject_GenericTryGetAttr(PyObject *, PyObject *);
 
 // Access macro to the members which are floating "behind" the object
 static inline PyMemberDef* _PyHeapType_GET_MEMBERS(PyHeapTypeObject *etype) {
index 9dd5eb998217f68c4ae2bfdfb4a44f4045ff950a..71f098eed37f51e756a61e510051be3eb9805171 100644 (file)
@@ -1491,12 +1491,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
     return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 0);
 }
 
-PyObject *
-_PyObject_GenericTryGetAttr(PyObject *obj, PyObject *name)
-{
-    return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 1);
-}
-
 int
 _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
                                  PyObject *value, PyObject *dict)
index 24541bddbbc33f6887ec4b8ded33846ff0b2ec4f..995547e7915f7791d49688c3bc5a59a81e23a88c 100644 (file)
@@ -8274,17 +8274,14 @@ _Py_slot_tp_getattr_hook(PyObject *self, PyObject *name)
         (Py_IS_TYPE(getattribute, &PyWrapperDescr_Type) &&
          ((PyWrapperDescrObject *)getattribute)->d_wrapped ==
          (void *)PyObject_GenericGetAttr))
-        /* finding nothing is reasonable when __getattr__ is defined */
-        res = _PyObject_GenericTryGetAttr(self, name);
+        res = PyObject_GenericGetAttr(self, name);
     else {
         Py_INCREF(getattribute);
         res = call_attribute(self, getattribute, name);
         Py_DECREF(getattribute);
     }
-    if (res == NULL) {
-        if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
-            PyErr_Clear();
-        }
+    if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+        PyErr_Clear();
         res = call_attribute(self, getattr, name);
     }
     Py_DECREF(getattr);