Fix __tracebackhide__ for ExceptionGroup frames sharing a source location - #14941
Open
Amine-LG wants to merge 1 commit into
Open
Fix __tracebackhide__ for ExceptionGroup frames sharing a source location#14941Amine-LG wants to merge 1 commit into
Amine-LG wants to merge 1 commit into
Conversation
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.
Fixes #14940.
_filter_tracebackexception()matched filtered traceback entries to Python's formatted frames using(filename, line number). Separate traceback entries can share those values while having different__tracebackhide__values, causing a hidden frame to remain visible.This change identifies each occurrence by the identity of its underlying raw traceback entry instead. Pytest's
TracebackEntryand Python'sFrameSummarysequences preserve traceback order, so they are walked together and only occurrences that survived filtering are kept.The pairing is non-strict because
sys.tracebacklimitcan shorten Python's formatted traceback. A separate test protects that behavior.This is a follow-up to the
ExceptionGrouptraceback filtering added in #14649.Tests
sys.tracebacklimitis set.python -m pytest -q testing/codepre-commit run --files AUTHORS changelog/14940.bugfix.rst src/_pytest/_code/code.py testing/code/test_excinfo.pyAI assistance
I used AI tools during the investigation and implementation. I manually reproduced the issue and reviewed and tested the final changes.