gh-96092: Fix traceback.walk_stack(None) skipping too many frames #129330
+25
−6
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.
Fixes #96092. Please see my comment in #99015 (comment) for more details on the root cause analysis of this issue.
This changes the
walk_stack
generator to capture the stack whenwalk_stack
is called, rather than when it is first iterated over. Since this is technically a breaking change in behavior, I added a versionchanged to the documentation. In practice, this is unlikely to break anyone, you would have been needing to store the result ofwalk_stack
and expecting it to change.It also adds a direct test for what the innermost frame
walk_stack
returns is.📚 Documentation preview 📚: https://cpython-previews--129330.org.readthedocs.build/