[issue10977] Concrete object C API needs abstract path for subclasses of builtin types

Raymond Hettinger report at bugs.python.org
Thu Apr 7 00:22:22 CEST 2011


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

One thing that could be done is to have an optional warning in the mutating concrete C API functions that gets triggered whenever the input doesn't have an exact type match.  That will let people discover incorrect uses.

We could also scour our own stdlib code to see if there are any cases where there needs to be an alternate code patch for subclasses of builtin types.

I did a scan for PyList_SetItem and found that we were already pretty good about only using it when the target was known to be an exact list. Though those results were good, I'm not hopeful for a similar result with PyDict_SetItem.

In the mean time this bug will preclude a C version of OrderedDict from being a dict subclass.  That's unfortunate because it means that the C version can't be a drop-in replacement for the existing pure python OrderedDict.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10977>
_______________________________________


More information about the Python-bugs-list mailing list