8000 gh-102213: Revert "gh-102213: Optimize the performance of `__getattr_… · python/cpython@059bb04 · GitHub
[go: up one dir, main page]

Skip to content

Commit 059bb04

Browse files
authored
gh-102213: Revert "gh-102213: Optimize the performance of __getattr__ (GH-102248)" (GH-103332)
This reverts commit aa0a73d.
1 parent efb0a2c commit 059bb04

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

Include/internal/pycore_object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ extern void _PyObject_FreeInstanceAttributes(PyObject *obj);
375375
extern int _PyObject_IsInstanceDictEmpty(PyObject *);
376376
extern int _PyType_HasSubclasses(PyTypeObject *);
377377
extern PyObject* _PyType_GetSubclasses(PyTypeObject *);
378-
extern PyObject* _PyObject_GenericTryGetAttr(PyObject *, PyObject *);
379378

380379
// Access macro to the members which are floating "behind" the object
381380
static inline PyMemberDef* _PyHeapType_GET_MEMBERS(PyHeapTypeObject *etype) {

Objects/object.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,12 +1491,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
14911491
return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 0);
14921492
}
14931493

1494-
PyObject *
1495-
_PyObject_GenericTryGetAttr(PyObject *obj, PyObject *name)
1496-
{
1497-
return _PyObject_GenericGetAttrWithDict(obj, name, NULL, 1);
1498-
}
1499-
15001494
int
15011495
_PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
15021496
PyObject *value, PyObject *dict)

Objects/typeobject.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8274,17 +8274,14 @@ _Py_slot_tp_getattr_hook(PyObject *self, PyObject *name)
82748274
(Py_IS_TYPE(getattribute, &PyWrapperDescr_Type) &&
82758275
((PyWrapperDescrObject *)getattribute)->d_wrapped ==
82768276
(void *)PyObject_GenericGetAttr))
8277-
/* finding nothing is reasonable when __getattr__ is defined */
8278-
res = _PyObject_GenericTryGetAttr(self, name);
8277+
res = PyObject_GenericGetAttr(self, name);
82798278
else {
82808279
Py_INCREF(getattribute);
82818280
res = call_attribute(self, getattribute, name);
82828281
Py_DECREF(getattribute);
82838282
}
8284-
if (res == NULL) {
8285-
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
8286-
PyErr_Clear();
8287-
}
8283+
if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
8284+
PyErr_Clear();
82888285
res = call_attribute(self, getattr, name);
82898286
}
82908287
Py_DECREF(getattr);

0 commit comments

Comments
 (0)
0