Skip to content

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

Closed

Description

@mjpieters
mannequin
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']

    Activity

    1. mjpieters commented on May 31, 2017

      mjpietersmannequin
      MannequinAuthor

      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

    2. mjpieters commented on May 31, 2017

      mjpietersmannequin
      MannequinAuthor
    3. added
      type-bugAn unexpected behavior, bug, or error
      on May 31, 2017
    4. serhiy-storchaka commented on May 31, 2017

      @serhiy-storchaka
      Member

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

    5. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      and removed on May 31, 2017
    6. vstinner commented on May 31, 2017

      @vstinner
      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.

    7. serhiy-storchaka commented on May 31, 2017

      @serhiy-storchaka
      Member

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

    8. vstinner commented on Jun 9, 2017

      @vstinner
      Member

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

    9. vstinner commented on Jun 9, 2017

      @vstinner
      Member

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

    10. vstinner commented on Jun 9, 2017

      @vstinner
      Member

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

    11. vstinner commented on Jun 9, 2017

      @vstinner
      Member

      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 :-)

    12. vstinner commented on Jun 20, 2017

      @vstinner
      Member

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

    13. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions