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.

Author Bryan Koch
Recipients Bryan Koch
Date 2019-01-16.23:42:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547682129.59.0.632977183775.issue35756@roundup.psfhosted.org>
In-reply-to
Content
Using the new "`return value` is semantically equivalent to `raise StopIteration(value)`" syntax created in PEP-380 (https://legacy.python.org/dev/peps/pep-0380/#formal-semantics) causes the returned value to be skipped by standard methods of iteration.

The PEP reads as if returning a value via StopIteration was meant to signal that the generator was finished and that StopIteration.value was the final value.  If StopIteration.value is meant to represent the final value, then the built-in for-loop should not skip it and the current implementation in 3.3, 3.4, 3.5, and 3.6 should be considered an oversight of the PEP and a bug (I don't have a version of 3.7 or 3.8 to test newer versions).

Reproduction code is attached with comments/annotations.
History
Date User Action Args
2019-01-16 23:42:12Bryan Kochsetrecipients: + Bryan Koch
2019-01-16 23:42:09Bryan Kochsetmessageid: <1547682129.59.0.632977183775.issue35756@roundup.psfhosted.org>
2019-01-16 23:42:09Bryan Kochlinkissue35756 messages
2019-01-16 23:42:09Bryan Kochcreate