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
gh-99947: Ensure unreported error is chained for SystemError during import #99946
base: main
Are you sure you want to change the base?
Conversation
Debugging a small issue in SciPy was made a bit tricky by the error being cleared seemingly unnecessary here. This ensures that module load errors chain their exceptions when this occurs (similar to function calls). Expanded the test to check that the `__cause__` is set where it seems that it should be.
self.load_module_by_name(name) | ||
|
||
# If there is an unreported exception, it should be chained |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# If there is an unreported exception, it should be chained | |
# If there is an unreported exception, it should be chained with the `SystemError`. |
self.load_module_by_name(name) | ||
|
||
# If there is an unreported exception, it should be chained | ||
if "unreported_exception" in name_base: | ||
self.assertIsNot(cm.exception.__cause__, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertIsNot(cm.exception.__cause__, None) | |
self.assertIsNotNone(cm.exception.__cause__) |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@@ -0,0 +1 @@ | |||
SystemErrors on import now chain the original unexpected exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SystemErrors on import now chain the original unexpected exception | |
Raising SystemError on import will now have its cause be set to the original unexpected exception. |
Co-authored-by: Brett Cannon <brett@python.org>
Adopted the improvements, thanks. Its a minor help with debugging, but would have saved me time twice in the past 1-2 months. EDIT: I guess the bot maybe expects exact wording "I have made the requested changes; please review again" |
"I have made the requested changes; please review again" EDIT: Oops, missed the review request and thought the bot labelling was confusing, sorry. |
Thanks for making the requested changes! @brettcannon: please review the changes made to this pull request. |
Before this change the triggering exception was dropped.