C implementation of OrderedDict often has two paths. One for exact OrderedDict and other for subclasses. But only one of the paths is tested. Proposed patch adds tests for a subclass of C implemented OrderedDict. test_issue24347 is failed with OrderedDict subclass. Either there is a bug in OrderedDict implementation, or the test should be more lenient.
The patch was not ready for commit. The problem is that test_issue24347 fails in CPythonOrderedDictSubclassTests. The failure is random, you need to run test several times to encounter it. Experimenting with this test I found other bug probably related to . >>> from collections import OrderedDict >>> od = OrderedDict() >>> dict.__setitem__(od, 1, 2) >>> od OrderedDict([]) I expected rather raising an exception or showing an empty OrderedDict, that exposing NULL.
New patch adds PurePythonOrderedDictSubclassTests, moves all tests except test_key_change_during_iteration from CPythonOrderedDictTests to OrderedDictTests to test Python implementation too, fixes a bug in values and items iteration that caused test_issue24347 to fail, and adds additional explicit checks for values() and items() to test_issue24347.