Message329260
> 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. |
|
| Date |
User |
Action |
Args |
| 2018-11-04 21:31:17 | rhettinger | set | recipients:
+ rhettinger, python-dev, eric.snow, serhiy.storchaka, bup, cheryl.sabella |
| 2018-11-04 21:31:17 | rhettinger | set | messageid: <[email protected]> |
| 2018-11-04 21:31:17 | rhettinger | link | issue25410 messages |
| 2018-11-04 21:31:17 | rhettinger | create | |
|