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 <rep...@bugs.python.org>
<http://bugs.python.org/issue16894>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to