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, steven.daprano
Date 2019-01-17.02:59:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547693979.62.0.927229132748.issue35756@roundup.psfhosted.org>
In-reply-to
Content
I understood the PEP to include `return expr` in the iteration values as per the first bullet of the proposal.

> Any values that the iterator yields are passed directly to the caller.

This bullet doesn't have any additional formatting on the word "yields" so I consider it as not directly referring to the "yield" keyword.

With the current implementation, I have to concern myself if a generator function was created with the intention of being called using `last_ret = yield from function(); yield last_ret` or as `for ret in function(): yield ret`.  The first also yields the return value but would also yield an additional `None` if a `return` was not the terminal cause; the second will miss the last value if the generator uses `return`.

Essentially, allowing `return expr` in generator functions without invoking the generator using `yield from generator` will lose the last value.

I support either of the below resolutions:
* `return expr` being invoked from a generator that is not being iterated using `yield from generator` is a SyntaxError
* `return expr` being invoked from a generator that is not being iterated using `yield from generator` includes the final return value in the iterated set
History
Date User Action Args
2019-01-17 02:59:41Bryan Kochsetrecipients: + Bryan Koch, steven.daprano
2019-01-17 02:59:39Bryan Kochsetmessageid: <1547693979.62.0.927229132748.issue35756@roundup.psfhosted.org>
2019-01-17 02:59:39Bryan Kochlinkissue35756 messages
2019-01-17 02:59:39Bryan Kochcreate