Repository navigation
Fix bad-exception-cause false positive when the cause's bases are unknown - #11399
Merged
Pierre-Sassoulas merged 2 commits intoSep 13, 2026
Merged
Conversation
inherit_from_std_ex walks ancestors() looking for BaseException, so a class whose base cannot be inferred (a C extension, a conditional import) looks like a non-exception and `raise ... from exc` is flagged. The sibling checks raising-non-exception and catching-non-exception already guard that case with has_known_bases, but _check_bad_exception_cause did not. Reproduced on anyio/to_interpreter.py, whose ExecutionFailed derives from _interpreters.InterpreterError.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11399 +/- ##
=======================================
Coverage 96.48% 96.48%
=======================================
Files 178 178
Lines 20407 20409 +2
=======================================
+ Hits 19689 19691 +2
Misses 718 718
🚀 New features to boost your workflow:
|
Contributor
|
🤖 Effect of this PR on checked open source code: 🤖 Effect on sentry: Removed messages: Details
This comment was generated for commit 5dfc4ae |
Pierre-Sassoulas
added a commit
that referenced
this pull request
Sep 14, 2026
…hen the cause's bases are unknown (#11419) Fix bad-exception-cause false positive when the cause's bases are unknown (#11399) inherit_from_std_ex walks ancestors() looking for BaseException, so a class whose base cannot be inferred (a C extension, a conditional import) looks like a non-exception and `raise ... from exc` is flagged. The sibling checks raising-non-exception and catching-non-exception already guard that case with has_known_bases, but _check_bad_exception_cause did not. Reproduced on anyio/to_interpreter.py, whose ExecutionFailed derives from _interpreters.InterpreterError. (cherry picked from commit a443dd3) Co-authored-by: kdelay <90545043+kdelay@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
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.
Type of Changes
Description
inherit_from_std_exlooks forBaseExceptioninancestors(), so a class whose base cannot be inferred (a C extension, a conditional import) reads as a non-exception.raising-non-exceptionandcatching-non-exceptionalready pair that helper withhas_known_bases._check_bad_exception_causedid not.Reproduced on
anyio/to_interpreter.py:55, whereExecutionFailedderives from_interpreters.InterpreterErrorandancestors()comes back empty:E0705 fires there while
catching-non-exceptionstays silent on the same handler.