Author belopolsky
Recipients arigo, belopolsky, christian.heimes, dalke, loewis, rhettinger, tds333
Date 2008-02-23.23:22:36
SpamBayes Score 0.0109434
Marked as misclassified No
Message-id <>
I would say dict's failure to call overloaded __setitem__ from 
setdefault is a dict implementation problem which should be either 
fixed, or clearly documented as warning to anyone who wants to derive 
from dict.

A fix would be trivial:

--- Objects/dictobject.c        (revision 61014)
+++ Objects/dictobject.c        (working copy)
@@ -1861,7 +1861,7 @@
        val = ep->me_value;
        if (val == NULL) {
                val = failobj;
-               if (PyDict_SetItem((PyObject*)mp, key, failobj))
+               if (PyObject_SetItem(mp, key, failobj))
                        val = NULL;

but I have no clue what performance or other implications would be.

Maybe something like this could be considered for Py3k - reviewing dict 
implementation to make it usable as DictMixin.  I'll write a complete 
patch if there is positive reaction.
Date User Action Args
2008-02-23 23:22:37belopolskysetspambayes_score: 0.0109434 -> 0.0109434
recipients: + belopolsky, loewis, arigo, rhettinger, dalke, tds333, christian.heimes
2008-02-23 23:22:37belopolskysetspambayes_score: 0.0109434 -> 0.0109434
messageid: <>
2008-02-23 23:22:36belopolskylinkissue1367711 messages
2008-02-23 23:22:36belopolskycreate