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

2011-11-06 Thread Raymond Hettinger
On Nov 6, 2011, at 1:26 PM, Martin v. Löwis wrote: > Am 06.11.2011 17:39, schrieb Antoine Pitrou: >> Le 05/11/2011 17:34, Éric Araujo a écrit : >>> Hi Victor, >>> PyDict_GetItem() and PyDict_SetItem() don't call __getitem__ and __setitem__ for dict subclasses. Is there a reason fo

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

2011-11-06 Thread Martin v. Löwis
Am 06.11.2011 17:39, schrieb Antoine Pitrou: > Le 05/11/2011 17:34, Éric Araujo a écrit : >> 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, th

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

2011-11-06 Thread Antoine Pitrou
Le 05/11/2011 17:34, Éric Araujo a écrit : 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 subclasse

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 _

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

[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