Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test OrderedDict subclass #69635

Closed
serhiy-storchaka opened this issue Oct 20, 2015 · 7 comments
Closed

Test OrderedDict subclass #69635

serhiy-storchaka opened this issue Oct 20, 2015 · 7 comments
Assignees
Labels
extension-modules C modules in the Modules dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 25449
Nosy @ericvsmith, @ericsnowcurrently, @serhiy-storchaka
Files
  • odict_subclass_test.patch
  • odict_subclass_test_2.patch
  • 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:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-11-04.20:40:14.342>
    created_at = <Date 2015-10-20.21:12:18.495>
    labels = ['extension-modules', 'type-bug', 'tests']
    title = 'Test OrderedDict subclass'
    updated_at = <Date 2015-11-04.20:40:14.340>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-11-04.20:40:14.340>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-11-04.20:40:14.342>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'Tests']
    creation = <Date 2015-10-20.21:12:18.495>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['40827', '40832']
    hgrepos = []
    issue_num = 25449
    keywords = ['patch']
    message_count = 7.0
    messages = ['253254', '253260', '253277', '253292', '253302', '254068', '254070']
    nosy_count = 4.0
    nosy_names = ['eric.smith', 'python-dev', 'eric.snow', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25449'
    versions = ['Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement extension-modules C modules in the Modules dir tests Tests in the Lib/test dir labels Oct 20, 2015
    @ericsnowcurrently
    Copy link
    Member

    LGTM as long as you also add PurePythonOrderedDictSubclassTests to match CPythonOrderedDictSubclassTests (per PEP-399).

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @ericsnowcurrently
    Copy link
    Member

    Regarding dict.__setitem__, see issue bpo-24726. Raymond outlined what needs to be fixed.

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Oct 21, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 4, 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/499398d91b97

    New 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/9db4191723eb

    New 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/59c7615ea921

    New 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/76e848554b5d

    @serhiy-storchaka
    Copy link
    Member Author

    59c7615ea921 and 76e848554b5d were related to bpo-24726.

    @serhiy-storchaka serhiy-storchaka self-assigned this Nov 4, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants