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
Comments
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 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 |
Forgot to addthis: this bug was found via https://stackoverflow.com/questions/44283540/iter-not-working-with-datetime-now |
It works in 3.5 and 3.7, but raises a StopIteration in 3.6. |
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. |
next(iter(datetime.now, None)) can be turned into a nice test. |
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 :-) |
bpo-30473 has been marked as a duplicate of this bug. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: