[Python-Dev] PyDict_Get/SetItem and dict subclasses

2011-11-05 Thread Victor Stinner
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

Re: [Python-Dev] PyDict_Get/SetItem and dict subclasses

2011-11-05 Thread Benjamin Peterson
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

Re: [Python-Dev] PyDict_Get/SetItem and dict subclasses

2011-11-05 Thread Éric Araujo
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 _

[Python-Dev] Why does _PyUnicode_FromId return a new reference?

2011-11-05 Thread Antoine Pitrou
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