Hi,
PyDict_GetItem() and PyDict_SetItem() don't call __getitem__ and __setitem__
for dict subclasses. Is there a reason for that?
I found this surprising behaviour when I replaced a dict by a custom dict
checking the key type on set. But my __setitem__ was not called because the
function using
2011/11/5 Victor Stinner :
> Hi,
>
> PyDict_GetItem() and PyDict_SetItem() don't call __getitem__ and __setitem__
> for dict subclasses. Is there a reason for that?
It's the same reason that PyUnicode_Concat doesn't call __add__ on
unicode subclasses or PyList_Append doesn't call "append" on list
Hi Victor,
> PyDict_GetItem() and PyDict_SetItem() don't call __getitem__ and __setitem__
> for dict subclasses. Is there a reason for that?
http://bugs.python.org/issue10977 “Currently, the concrete object C API
bypasses any methods defined on subclasses of builtin types.”
Cheers
_
Given it returns an eternal object, and it's almost always used
temporarily (for attribute lookup, string joining, etc.), it would seem
more practical for it to return a borrowed reference.
Regards
Antoine.
___
Python-Dev mailing list
Python-Dev@pyth