Skip to content

gh-132308: TracebackException swallows attributes of falsey Exception and falsey ExceptionGroup #132363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

YvesDup
Copy link
Contributor

@YvesDup YvesDup commented Apr 10, 2025

Summary

An x is falsey if len(x) returns 0 or bool(x) returns False

TracebackException class swallows the following attributes of falsey Exception:

  • __cause__
  • __context__

TracebackException swallows all sub-exceptions of falsey ExceptionGroup

The fix is located in the __init__ method of the TracebackException class.

@picnixz picnixz self-assigned this Apr 19, 2025
@picnixz picnixz enabled auto-merge (squash) April 19, 2025 08:50
@picnixz picnixz merged commit 69cda31 into python:main Apr 19, 2025
39 checks passed
@brianschubert
Copy link
Contributor

@picnixz backport to 3.13?

@picnixz picnixz added the needs backport to 3.13 bugs and security fixes label Apr 19, 2025
@miss-islington-app
Copy link

Thanks @YvesDup for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@picnixz
Copy link
Member

picnixz commented Apr 19, 2025

Yes, I forgot about it :') Thanks for the reminder

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 19, 2025
…f a falsey `Exception` or `ExceptionGroup` (pythonGH-132363)

(cherry picked from commit 69cda31)

Co-authored-by: Duprat <yduprat@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Apr 19, 2025

GH-132725 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 19, 2025
@YvesDup
Copy link
Contributor Author

YvesDup commented Apr 29, 2025

@picnixz FYI the backport GH-132725 is not merged. Do I wait for to delete my branch ?

@picnixz
Copy link
Member

picnixz commented Apr 30, 2025

No it's fine. I'm on my way to the airport, I'll merge it in a few hours. Thanks for the reminder!

picnixz pushed a commit that referenced this pull request Apr 30, 2025
…of a falsey `Exception` or `ExceptionGroup` (GH-132363) (#132725)

gh-132308: prevent `TracebackException` swallowing attributes of a falsey `Exception` or `ExceptionGroup` (GH-132363)
(cherry picked from commit 69cda31)

Co-authored-by: Duprat <yduprat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants