You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve return values from generator callers - #191
Generator callers currently lose their return value in decorate(). An identity caller using return (yield from func(...)) yields the wrapped generator's items correctly, but exhausting the decorated generator raises StopIteration(None) even when the caller returns 42.
Return the result of the wrapper's yield from expression so generator composition preserves that value as well as yielded items.
Validation: the new regression observes the yielded item and StopIteration.value, and fails against the unmodified source. All 29 tests, including documentation examples, pass on CPython 3.12. git diff --check passes.
Prepared with OpenAI Codex assistance; no manual human testing is claimed.
The test sends a value into the decorated generator, then throws a ValueError that the generator handles by returning a sentinel. It checks the returned object's identity, both finally blocks, and that the generator frame closes.
On Windows / CPython 3.14.4, it passes at aa9b563; the base loses the sentinel and returns None. The existing yielded-items control passes on both versions. These are focused checks, not a full-suite, documentation, or cross-version CI run.
Optional suggestion: keep this beside normal exhaustion, since yielded items can look right while a handled-error completion still loses its result.
Thanks for checking completion through throw() and sharing the test. The returned sentinel and both finally blocks cover a useful path beyond normal exhaustion. I have reviewed the proposed test, but have not applied the optional commit or run it locally.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generator callers currently lose their return value in
decorate(). An identity caller usingreturn (yield from func(...))yields the wrapped generator's items correctly, but exhausting the decorated generator raisesStopIteration(None)even when the caller returns42.Return the result of the wrapper's
yield fromexpression so generator composition preserves that value as well as yielded items.Validation: the new regression observes the yielded item and
StopIteration.value, and fails against the unmodified source. All 29 tests, including documentation examples, pass on CPython 3.12.git diff --checkpasses.Prepared with OpenAI Codex assistance; no manual human testing is claimed.