Issue 30524: iter(classmethod, sentinel) broken for Argument Clinic class methods? (original) (raw)
Created on 2017-05-31 12:01 by mjpieters, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (10)
Author: Martijn Pieters (mjpieters) *
Date: 2017-05-31 12:01
I'm not sure where exactly the error lies, but issue 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 "", line 1, in StopIteration next(iter(Task.all_tasks, None)) Traceback (most recent call last): File "", line 1, in 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 https://github.com/python/cpython/commit/99ee9c70a73ec2f3db68785821a9f2867c3f637f
Author: Martijn Pieters (mjpieters) *
Date: 2017-05-31 12:09
Forgot to addthis: this bug was found via https://stackoverflow.com/questions/44283540/iter-not-working-with-datetime-now
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2017-05-31 12:30
It works in 3.5 and 3.7, but raises a StopIteration in 3.6.
Author: STINNER Victor (vstinner) *
Date: 2017-05-31 14:41
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 :-(
https://github.com/python/cpython/pull/1886 fixes the bug, but has not test yet.
Author: Serhiy Storchaka (serhiy.storchaka) *
Date: 2017-05-31 16:10
next(iter(datetime.now, None)) can be turned into a nice test.
Author: STINNER Victor (vstinner) *
Date: 2017-06-09 11:24
New changeset f0ff849adc6b4a01f9d1f08d9ad0f1511ff84541 by Victor Stinner in branch '3.6': bpo-30524: Fix _PyStack_UnpackDict() (#1886) https://github.com/python/cpython/commit/f0ff849adc6b4a01f9d1f08d9ad0f1511ff84541
Author: STINNER Victor (vstinner) *
Date: 2017-06-09 14:48
New changeset 3b5cf85edc188345668f987c824a2acb338a7816 by Victor Stinner in branch 'master': bpo-30524: Write unit tests for FASTCALL (#2022) https://github.com/python/cpython/commit/3b5cf85edc188345668f987c824a2acb338a7816
Author: STINNER Victor (vstinner) *
Date: 2017-06-09 20:28
New changeset b7577456c430283f8b7ec4e914b701cb943cc69b by Victor Stinner in branch '3.6': bpo-30524: Write unit tests for FASTCALL (#2022) (#2030) https://github.com/python/cpython/commit/b7577456c430283f8b7ec4e914b701cb943cc69b
Author: STINNER Victor (vstinner) *
Date: 2017-06-09 20:45
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 :-)
Author: STINNER Victor (vstinner) *
Date: 2017-06-20 20:34
bpo-30473 has been marked as a duplicate of this bug.
History
Date
User
Action
Args
2022-04-11 14:58:47
admin
set
github: 74709
2017-06-20 20:34:33
vstinner
set
messages: +
2017-06-20 20:34:13
vstinner
link
2017-06-09 20:45:17
vstinner
set
status: open -> closed
resolution: fixed
messages: +
stage: needs patch -> resolved
2017-06-09 20:28:35
vstinner
set
messages: +
2017-06-09 15:14:31
vstinner
set
pull_requests: + <pull%5Frequest2096>
2017-06-09 14:48:47
vstinner
set
messages: +
2017-06-09 11:24:56
vstinner
set
messages: +
2017-06-09 11:23:48
vstinner
set
pull_requests: + <pull%5Frequest2088>
2017-05-31 16:10:41
serhiy.storchaka
set
messages: +
2017-05-31 15:08:49
rhettinger
set
priority: normal -> high
2017-05-31 14:41:03
vstinner
set
messages: +
2017-05-31 14:39:28
vstinner
set
pull_requests: + <pull%5Frequest1962>
2017-05-31 12:30:35
serhiy.storchaka
set
keywords: + 3.6regression
messages: +
components: + Interpreter Core
versions: - Python 3.7
2017-05-31 12:19:35
abarry
set
nosy: + vstinner, serhiy.storchaka
type: behavior
stage: needs patch
2017-05-31 12:09:35
mjpieters
set
messages: +
2017-05-31 12:01:15
mjpieters
create