Repository navigation
Test OrderedDict subclass #69635
Description
Activity
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.
- addedtype-featureA feature request or enhancementA feature request or enhancementextension-modulesC modules in the Modules dirC modules in the Modules dirtestsTests in the Lib/test dirTests in the Lib/test dir
on Oct 20, 2015 LGTM as long as you also add PurePythonOrderedDictSubclassTests to match CPythonOrderedDictSubclassTests (per PEP-399).
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 bpo-24347.
>>> from collections import OrderedDict >>> od = OrderedDict() >>> dict.__setitem__(od, 1, 2) >>> od OrderedDict([<NULL>])
I expected rather raising an exception or showing an empty OrderedDict, that exposing NULL.
Regarding dict.__setitem__, see issue bpo-24726. Raymond outlined what needs to be fixed.
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.
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorand removedtype-featureA feature request or enhancementA feature request or enhancement
on Oct 21, 2015 New changeset 499398d91b97 by Serhiy Storchaka in branch '3.5':
Issue bpo-25449: Iterating OrderedDict with keys with unstable hash now raises
https://hg.python.org/cpython/rev/499398d91b97New changeset 9db4191723eb by Serhiy Storchaka in branch 'default':
Issue bpo-25449: Iterating OrderedDict with keys with unstable hash now raises
https://hg.python.org/cpython/rev/9db4191723ebNew changeset 59c7615ea921 by Serhiy Storchaka in branch '3.5':
Issue bpo-25449: Fixed a crash and leaking NULL in repr() of OrderedDict that
https://hg.python.org/cpython/rev/59c7615ea921New changeset 76e848554b5d by Serhiy Storchaka in branch 'default':
Issue bpo-25449: Fixed a crash and leaking NULL in repr() of OrderedDict that
https://hg.python.org/cpython/rev/76e848554b5d59c7615ea921 and 76e848554b5d were related to bpo-24726.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: