You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iter(classmethod, sentinel) broken for Argument Clinic class methods? #74709
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:
>>> 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
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 :-)
Activity
mjpieters commentedon 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:
In 3.6 StopIteration is raised:
(In 3.5 a
datetime.datetimeandsetobject 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 commentedon May 31, 2017
Forgot to addthis: this bug was found via https://stackoverflow.com/questions/44283540/iter-not-working-with-datetime-now
serhiy-storchaka commentedon May 31, 2017
It works in 3.5 and 3.7, but raises a StopIteration in 3.6.
vstinner commentedon May 31, 2017
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 commentedon May 31, 2017
next(iter(datetime.now, None)) can be turned into a nice test.
vstinner commentedon Jun 9, 2017
New changeset f0ff849 by Victor Stinner in branch '3.6':
bpo-30524: Fix _PyStack_UnpackDict() (bpo-1886)
f0ff849
vstinner commentedon Jun 9, 2017
New changeset 3b5cf85 by Victor Stinner in branch 'master':
bpo-30524: Write unit tests for FASTCALL (bpo-2022)
3b5cf85
vstinner commentedon 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 commentedon 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 commentedon Jun 20, 2017
bpo-30473 has been marked as a duplicate of this bug.