[FIX] reraise __cause__ of the CodeEvaluationError if it exists #48
Closed
benwillig wants to merge 1 commit into
Closed
[FIX] reraise __cause__ of the CodeEvaluationError if it exists #48benwillig wants to merge 1 commit into
benwillig wants to merge 1 commit into
Conversation
sbidoul
previously approved these changes
Jul 5, 2024
… want the final exception before CodeEvaluationError and not the root one
fc43145 to
bb621c5
Compare
Member
|
@sbejaoui The previous recursion mechanism was inherited the python 2 era. Maybe worth checking if this works for your project too? |
Member
|
I'm slightly worried that some projects could depend on the current behaviour of recursively looking for the cause. So I propose to not merge ths in 16 and take it in 18 only. |
sbidoul
reviewed
Aug 13, 2025
Comment on lines
+12
to
+15
| cause_exc = getattr(e, "__cause__", None) | ||
| if cause_exc: | ||
| return cause_exc | ||
| return e |
Member
There was a problem hiding this comment.
Suggested change
| cause_exc = getattr(e, "__cause__", None) | |
| if cause_exc: | |
| return cause_exc | |
| return e | |
| return getattr(e, "__cause__", e) |
This could be simplified like this, or even inlined at the two places where this is used, since the _root_cause name does not meany much anymore.
Member
There was a problem hiding this comment.
Rather, (e.__cause__ or e), because __cause__ is part of BaseException so getattr should not be necessary anymore.
Member
|
So closing. This is included in #49 for 18.0. |
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.
No description provided.