Message329260
| Author |
rhettinger |
| Recipients |
bup, cheryl.sabella, eric.snow, python-dev, rhettinger, serhiy.storchaka |
| Date |
2018年11月04日.21:31:17 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1541367077.4.0.788709270274.issue25410@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> Maybe it's considered undefined behavior for a subclass to use
> a method of one of its bases which it has overriden.
In general, it's true that if OrderedDict is a subclass of dict, then it would have no defense against someone making a direct call to the dict base class. Such a call should be expected to violate the OrderedDicts invariants.
> it's a complete coin toss on whether one of the many internal
> API function will set an attribute or name via PyDict_SetItem
> or PyObject_SetItem.
Not really. The CPython source is supposed to only call PyDict_SetItem when the target is known to be an exact dictionary. If you find a case where that isn't true, please file a bug report and we'll fix it.
> It might be more appropriate to start a new issue for this, but I'll > leave that decision to somehow who would know for sure.
No need. We've known about this sort of problem for years. See https://bugs.python.org/issue10977 for example. There isn't really much we could do about it without causing other issues that would be worse.
FWIW, this doesn't seem to be a problem in practice. Further, OrderedDict is expected to become less relevant now that regular dicts are order preserving. |
|