fix: forward generator return value through the trampoline - #542
Merged
boxed merged 1 commit intoJul 31, 2026
Merged
Conversation
wrap_in_trampoline's generator branch used a bare "yield from trampoline(...)", so the wrapper generator always finished with an implicit None. A caller doing "result = yield from decorated_gen()" therefore got None instead of the generator's return value, and any test asserting on that value failed under "mutmut run" while passing under plain pytest. Returning the delegation result matches the PEP 380 expansion and mirrors the equivalent fix already applied to the async-generator branch. Adds a returning generator to the trampoline test module plus original and mutated regression tests that consume it with "yield from".
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #540
The generator branch of
wrap_in_trampolineused a bareyield from trampoline(...), so the wrapper generator always ended with an implicitNone. A caller doingresult = yield from decorated_gen()lost the generator's return value, making tests that assert on it fail undermutmut runwhile passing under plain pytest. Returning the delegation result matches the PEP 380 expansion, mirroring the equivalent fix already made for async generators in #525.Added a returning generator plus original/mutated regression tests to
tests/mutation/test_trampoline.py; both fail on the current code and pass with the fix.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.