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

iter(classmethod, sentinel) broken for Argument Clinic class methods? #74709

Closed
mjpieters mannequin opened this issue May 31, 2017 · 10 comments
Closed

iter(classmethod, sentinel) broken for Argument Clinic class methods? #74709

mjpieters mannequin opened this issue May 31, 2017 · 10 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@mjpieters
Copy link
Mannequin

mjpieters mannequin commented May 31, 2017

BPO 30524
Nosy @mjpieters, @vstinner, @serhiy-storchaka
PRs
  • bpo-30524: Fix _PyStack_UnpackDict() #1886
  • bpo-30524: Write unit tests for FASTCALL #2022
  • [3.6] bpo-30524: Write unit tests for FASTCALL (#2022) #2030
  • 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 2017-06-09.20:45:17.849>
    created_at = <Date 2017-05-31.12:01:15.958>
    labels = ['interpreter-core', 'type-bug']
    title = 'iter(classmethod, sentinel) broken for Argument Clinic class methods?'
    updated_at = <Date 2017-06-20.20:34:33.131>
    user = 'https://github.com/mjpieters'

    bugs.python.org fields:

    activity = <Date 2017-06-20.20:34:33.131>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-06-09.20:45:17.849>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2017-05-31.12:01:15.958>
    creator = 'mjpieters'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30524
    keywords = ['3.6regression']
    message_count = 10.0
    messages = ['294835', '294836', '294841', '294845', '294847', '295515', '295535', '295566', '295572', '296486']
    nosy_count = 3.0
    nosy_names = ['mjpieters', 'vstinner', 'serhiy.storchaka']
    pr_nums = ['1886', '2022', '2030']
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30524'
    versions = ['Python 3.6']

    @mjpieters
    Copy link
    Mannequin Author

    mjpieters mannequin commented May 31, 2017

    I'm not sure where exactly the error lies, but bpo-27128 broke iter() for Argument Clinic class methods. The following works in Python 3.5, but not in Python 3.6:

    from datetime import datetime
    from asyncio import Task
    
    next(iter(datetime.now, None))
    next(iter(Task.all_tasks, None))

    In 3.6 StopIteration is raised:

    >>> next(iter(datetime.now, None))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    StopIteration
    >>> next(iter(Task.all_tasks, None))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    StopIteration

    (In 3.5 a datetime.datetime and set object are produced, respectively)

    The only thing these two methods have in common is that they are class methods with no arguments, parsed out by the Argument Clinic generated code (so using _PyArg_Parser).

    What appears to have changed is that iter() was switched from using PyObject_Call to _PyObject_FastCall, see 99ee9c7

    @mjpieters mjpieters mannequin added the 3.7 (EOL) end of life label May 31, 2017
    @mjpieters
    Copy link
    Mannequin Author

    mjpieters mannequin commented May 31, 2017

    Forgot to addthis: this bug was found via https://stackoverflow.com/questions/44283540/iter-not-working-with-datetime-now

    @Vgr255 Vgr255 mannequin added the type-bug An unexpected behavior, bug, or error label May 31, 2017
    @serhiy-storchaka
    Copy link
    Member

    It works in 3.5 and 3.7, but raises a StopIteration in 3.6.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed 3.7 (EOL) end of life labels May 31, 2017
    @vstinner
    Copy link
    Member

    Oh, it's my fault: it's a bug coming from FASTCALL optimizations. The strange thing is that the bug wasn't catched by the giant Python test suite :-(

    I knew that _PyStack_UnpackDict() has a bug in Python 3.6, but I completely forgot to fix it :-(

    #1886 fixes the bug, but has not test yet.

    @serhiy-storchaka
    Copy link
    Member

    next(iter(datetime.now, None)) can be turned into a nice test.

    @vstinner
    Copy link
    Member

    vstinner commented Jun 9, 2017

    New changeset f0ff849 by Victor Stinner in branch '3.6':
    bpo-30524: Fix _PyStack_UnpackDict() (bpo-1886)
    f0ff849

    @vstinner
    Copy link
    Member

    vstinner commented Jun 9, 2017

    New changeset 3b5cf85 by Victor Stinner in branch 'master':
    bpo-30524: Write unit tests for FASTCALL (bpo-2022)
    3b5cf85

    @vstinner
    Copy link
    Member

    vstinner commented Jun 9, 2017

    New changeset b757745 by Victor Stinner in branch '3.6':
    bpo-30524: Write unit tests for FASTCALL (bpo-2022) (bpo-2030)
    b757745

    @vstinner
    Copy link
    Member

    vstinner commented Jun 9, 2017

    Sorry for the regression, sadly, it wasn't catch before by any test. I added a lot of new tests, so we should cover more cases. Oh, and the bug has been fixed in 3.6 :-)

    @vstinner vstinner closed this as completed Jun 9, 2017
    @vstinner
    Copy link
    Member

    bpo-30473 has been marked as a duplicate of this bug.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants