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

functools.singledispatchmethod is missing tests (and is buggy in 3.9) #89841

Closed
AlexWaygood opened this issue Oct 30, 2021 · 9 comments
Closed
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@AlexWaygood
Copy link
Member

BPO 45678
Nosy @rhettinger, @ambv, @miss-islington, @AlexWaygood
PRs
  • bpo-45678: Add functools.singledispatchmethod tests #29328
  • [3.10] bpo-45678: Add functools.singledispatchmethod tests (GH-29328) #29390
  • [3.9] bpo-45678: Add functools.singledispatchmethod tests (GH-29328) #29391
  • [3.9] bpo-45678: Fix singledispatchmethod classmethod/staticmethod bug #29394
  • bpo-45678: Add more singledispatchmethod tests #29412
  • [3.10] bpo-45678: Add more singledispatchmethod tests (GH-29412) #29424
  • 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 = None
    closed_at = <Date 2021-11-05.15:28:00.977>
    created_at = <Date 2021-10-30.12:10:31.370>
    labels = ['type-bug', '3.9', '3.10', '3.11', 'library', 'tests']
    title = '`functools.singledispatchmethod` is missing tests (and is buggy in 3.9)'
    updated_at = <Date 2021-11-05.15:28:00.976>
    user = 'https://github.com/AlexWaygood'

    bugs.python.org fields:

    activity = <Date 2021-11-05.15:28:00.976>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-05.15:28:00.977>
    closer = 'lukasz.langa'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2021-10-30.12:10:31.370>
    creator = 'AlexWaygood'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45678
    keywords = ['patch']
    message_count = 9.0
    messages = ['405366', '405626', '405630', '405652', '405746', '405748', '405781', '405803', '405804']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'lukasz.langa', 'miss-islington', 'AlexWaygood']
    pr_nums = ['29328', '29390', '29391', '29394', '29412', '29424']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45678'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @AlexWaygood
    Copy link
    Member Author

    test_functools includes a test to check that functools.singledispatch correctly wraps the attributes of the target function. However, there is no equivalent test for functools.singledispatchmethod. There should be, as this is done separately in the __get__ method of functools.singledispatchmethod; it is a different mechanism to functools.singledispatch.

    Additionally, test_abstractmethod_register tests that the return value of singledispatchmethod.__get__ wraps the target function's __isabstractmethod__ attribute. However, the __isabstractmethod__ property of the singledispatchmethod class is untested.

    @AlexWaygood AlexWaygood added stdlib Python modules in the Lib dir 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir and removed stdlib Python modules in the Lib dir labels Oct 30, 2021
    @ambv
    Copy link
    Contributor

    ambv commented Nov 3, 2021

    New changeset 5a14929 by Alex Waygood in branch 'main':
    bpo-45678: Add functools.singledispatchmethod tests (GH-29328)
    5a14929

    @ambv
    Copy link
    Contributor

    ambv commented Nov 3, 2021

    New changeset f191838 by Miss Islington (bot) in branch '3.10':
    bpo-45678: Add functools.singledispatchmethod tests (GH-29328) (GH-29390)
    f191838

    @AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Nov 3, 2021
    @AlexWaygood AlexWaygood changed the title functools.singledispatchmethod is missing tests functools.singledispatchmethod is missing tests (and is buggy in 3.9) Nov 3, 2021
    @AlexWaygood
    Copy link
    Member Author

    Backporting these tests to 3.9 revealed a bug in the 3.9 branch; PR 29394 is an attempt at fixing this bug.

    @ambv
    Copy link
    Contributor

    ambv commented Nov 4, 2021

    New changeset effb72f by Alex Waygood in branch '3.9':
    [3.9] bpo-45678: Fix singledispatchmethod classmethod/staticmethod bug (GH-29394)
    effb72f

    @AlexWaygood
    Copy link
    Member Author

    Yet more tests were added to the 3.9 branch in PR 29394 in order to test the bugfix. PR 29412 "forward-ports" these new tests into main (and 3.10, if they are backported).

    @ambv
    Copy link
    Contributor

    ambv commented Nov 5, 2021

    New changeset 32f55d1 by Alex Waygood in branch 'main':
    bpo-45678: Add more singledispatchmethod tests (GH-29412)
    32f55d1

    @ambv
    Copy link
    Contributor

    ambv commented Nov 5, 2021

    New changeset bcb236c by Miss Islington (bot) in branch '3.10':
    bpo-45678: Add more singledispatchmethod tests (GH-29412) (GH-29424)
    bcb236c

    @ambv
    Copy link
    Contributor

    ambv commented Nov 5, 2021

    Thanks, Alex! ✨ 🍰 ✨

    @ambv ambv closed this as completed Nov 5, 2021
    @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
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib 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