Skip to content

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

Merged
picnixz merged 16 commits into
python:mainfrom
YvesDup:TracebackException-swallows-cause-context-flasey-exception
Apr 19, 2025
Merged

gh-132308: TracebackException swallows attributes of falsey Exception and falsey ExceptionGroup#132363
picnixz merged 16 commits into
python:mainfrom
YvesDup:TracebackException-swallows-cause-context-flasey-exception

Conversation

@YvesDup

@YvesDup YvesDup commented Apr 10, 2025

Copy link
Copy Markdown
Contributor

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.

Comment thread Lib/test/test_traceback.py Outdated
Comment thread Misc/NEWS.d/next/Library/2025-04-10-13-06-42.gh-issue-132308.1js5SI.rst Outdated
Comment thread Lib/test/test_traceback.py Outdated
Comment thread Lib/test/test_traceback.py Outdated
Comment thread Misc/NEWS.d/next/Library/2025-04-10-13-06-42.gh-issue-132308.1js5SI.rst Outdated
Comment thread Lib/test/test_traceback.py
Comment thread Lib/test/test_traceback.py Outdated
Comment thread Misc/NEWS.d/next/Library/2025-04-10-13-06-42.gh-issue-132308.1js5SI.rst Outdated
@picnixz picnixz self-assigned this Apr 19, 2025
@picnixz picnixz enabled auto-merge (squash) April 19, 2025 08:50
Comment thread Misc/NEWS.d/next/Library/2025-04-10-13-06-42.gh-issue-132308.1js5SI.rst Outdated
@picnixz picnixz merged commit 69cda31 into python:main Apr 19, 2025
@brianschubert

Copy link
Copy Markdown
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
Copy Markdown

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

@picnixz

picnixz commented Apr 19, 2025

Copy link
Copy Markdown
Member

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

bedevere-app Bot commented Apr 19, 2025

Copy link
Copy Markdown

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

YvesDup commented Apr 29, 2025

Copy link
Copy Markdown
Contributor Author

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

@picnixz

picnixz commented Apr 30, 2025

Copy link
Copy Markdown
Member

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>
@YvesDup YvesDup deleted the TracebackException-swallows-cause-context-flasey-exception branch May 22, 2025 17:02
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