diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2022-08-17 11:37:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 11:37:07 (GMT) |
commit | 7276ca25f5f1440aa4d025350d3de15141854dde (patch) | |
tree | 253f8e34893018705c9f04810d68e2d798c1bd24 /Objects | |
parent | 36517101dd80cae93da379e95e98a688c52935b7 (diff) | |
download | cpython-7276ca25f5f1440aa4d025350d3de15141854dde.zip cpython-7276ca25f5f1440aa4d025350d3de15141854dde.tar.gz cpython-7276ca25f5f1440aa4d025350d3de15141854dde.tar.bz2 |
GH-93911: Specialize `LOAD_ATTR` for custom `__getattribute__` (GH-93988)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c881aeb..f796a91 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -8102,17 +8102,17 @@ slot_tp_call(PyObject *self, PyObject *args, PyObject *kwds) /* There are two slot dispatch functions for tp_getattro. - - slot_tp_getattro() is used when __getattribute__ is overridden + - _Py_slot_tp_getattro() is used when __getattribute__ is overridden but no __getattr__ hook is present; - - slot_tp_getattr_hook() is used when a __getattr__ hook is present. + - _Py_slot_tp_getattr_hook() is used when a __getattr__ hook is present. - The code in update_one_slot() always installs slot_tp_getattr_hook(); this - detects the absence of __getattr__ and then installs the simpler slot if - necessary. */ + The code in update_one_slot() always installs _Py_slot_tp_getattr_hook(); + this detects the absence of __getattr__ and then installs the simpler + slot if necessary. */ -static PyObject * -slot_tp_getattro(PyObject *self, PyObject *name) +PyObject * +_Py_slot_tp_getattro(PyObject *self, PyObject *name) { PyObject *stack[2] = {self, name}; return vectorcall_method(&_Py_ID(__getattribute__), stack, 2); @@ -8143,8 +8143,8 @@ call_attribute(PyObject *self, PyObject *attr, PyObject *name) return res; } -static PyObject * -slot_tp_getattr_hook(PyObject *self, PyObject *name) +PyObject * +_Py_slot_tp_getattr_hook(PyObject *self, PyObject *name) { PyTypeObject *tp = Py_TYPE(self); PyObject *getattr, *getattribute, *res; @@ -8157,8 +8157,8 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name) getattr = _PyType_Lookup(tp, &_Py_ID(__getattr__)); if (getattr == NULL) { /* No __getattr__ hook: use a simpler dispatcher */ - tp->tp_getattro = slot_tp_getattro; - return slot_tp_getattro(self, name); + tp->tp_getattro = _Py_slot_tp_getattro; + return _Py_slot_tp_getattro(self, name); } Py_INCREF(getattr); /* speed hack: we could use lookup_maybe, but that would resolve the @@ -8519,10 +8519,10 @@ static slotdef slotdefs[] = { PyWrapperFlag_KEYWORDS), TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc, "__str__($self, /)\n--\n\nReturn str(self)."), - TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, + TPSLOT("__getattribute__", tp_getattro, _Py_slot_tp_getattr_hook, wrap_binaryfunc, "__getattribute__($self, name, /)\n--\n\nReturn getattr(self, name)."), - TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""), + TPSLOT("__getattr__", tp_getattro, _Py_slot_tp_getattr_hook, NULL, ""), TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr, "__setattr__($self, name, value, /)\n--\n\nImplement setattr(self, name, value)."), TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr, |