[issue16894] Function attribute access doesn't invoke methods in dict subclasses
Eric Snow
report at bugs.python.org
Thu Jan 10 08:42:18 CET 2013
Eric Snow added the comment:
Looks like a case where the concrete dict API is ignoring subtype implementations.
In your example the attribute access will be handled by a LOAD_ATTR which calls PyObject_GetAttr() (Python/ceval.c:2369). That ends up calling PyFunction_Type.tp_getattro (inherited from PyBaseObject_Type).
That ends up just being PyObject_GenericGetAttr() (Objects/object.c:1061). The dict gets pulled from foo using PyFunction_Type.->tp_dictoffset and then PyDict_GetItem() gets called on it.
Unfortunately, PyDict_GetItem() is hard-coded to the dict implementation. At this point your __getitem__() has been entirely circumvented!
FYI, this is a pain point for myself right now so it's been on my mind (COrderedDict and kwargs). This came up in 2011. See issue 10977.
----------
nosy: +eric.snow
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16894>
_______________________________________
More information about the Python-bugs-list
mailing list