This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: iter(classmethod, sentinel) broken for Argument Clinic class methods?
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mjpieters, serhiy.storchaka, vstinner
Priority: high Keywords: 3.6regression

Created on 2017-05-31 12:01 by mjpieters, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1886 merged vstinner, 2017-05-31 14:39
PR 2022 merged vstinner, 2017-06-09 11:23
PR 2030 merged vstinner, 2017-06-09 15:14
Messages (10)
msg294835 - (view) 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 "<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 https://github.com/python/cpython/commit/99ee9c70a73ec2f3db68785821a9f2867c3f637f
msg294836 - (view) 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
msg294841 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-31 12:30
It works in 3.5 and 3.7, but raises a StopIteration in 3.6.
msg294845 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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.
msg294847 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-31 16:10
next(iter(datetime.now, None)) can be turned into a nice test.
msg295515 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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
msg295535 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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
msg295566 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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
msg295572 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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 :-)
msg296486 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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:47adminsetgithub: 74709
2017-06-20 20:34:33vstinnersetmessages: + msg296486
2017-06-20 20:34:13vstinnerlinkissue30473 superseder
2017-06-09 20:45:17vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg295572

stage: needs patch -> resolved
2017-06-09 20:28:35vstinnersetmessages: + msg295566
2017-06-09 15:14:31vstinnersetpull_requests: + pull_request2096
2017-06-09 14:48:47vstinnersetmessages: + msg295535
2017-06-09 11:24:56vstinnersetmessages: + msg295515
2017-06-09 11:23:48vstinnersetpull_requests: + pull_request2088
2017-05-31 16:10:41serhiy.storchakasetmessages: + msg294847
2017-05-31 15:08:49rhettingersetpriority: normal -> high
2017-05-31 14:41:03vstinnersetmessages: + msg294845
2017-05-31 14:39:28vstinnersetpull_requests: + pull_request1962
2017-05-31 12:30:35serhiy.storchakasetkeywords: + 3.6regression

messages: + msg294841
components: + Interpreter Core
versions: - Python 3.7
2017-05-31 12:19:35abarrysetnosy: + vstinner, serhiy.storchaka

type: behavior
stage: needs patch
2017-05-31 12:09:35mjpieterssetmessages: + msg294836
2017-05-31 12:01:15mjpieterscreate