This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients alex, brett.cannon, dabeaz, eric.snow
Date 2013-01-10.07:42:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357803738.76.0.563936077039.issue16894@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-01-10 07:42:18eric.snowsetrecipients: + eric.snow, brett.cannon, alex, dabeaz
2013-01-10 07:42:18eric.snowsetmessageid: <1357803738.76.0.563936077039.issue16894@psf.upfronthosting.co.za>
2013-01-10 07:42:18eric.snowlinkissue16894 messages
2013-01-10 07:42:18eric.snowcreate