-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-36829: Document test.support.catch_unraisable_exception() #13554
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
Doc/library/test.rst
Outdated
Usage:: | ||
|
||
with support.catch_unraisable_exception() as cm: | ||
# code creating an "unraisable 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.
Might be worth suggesting gc.collect()
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.
gc.collect() is not needed. Why do you want to force a GC collection?
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.
It's not needed but it's often a good trigger of these sort of exceptions
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.
Well, tests using the context manager expect an unraisable exception and fail if it's not the case.
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.
Oh. By the way. I also had the idea of installing a custom sys.unraisablehook in regrtest and repeat all errors at exit. Maybe even make the test fail if at least one unraisable exception is logged.
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.
Can you URL me to that commit?
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.
It's not a commit but an idea :-) I didn't implement it.
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.
Ok, :$ ping me when implemented!
Oh. "del self.unraisable" was a good idea. I only used the context manager in a few places, but I already get it wrong in test_io :-) It's now fixed by this PR! |
catch_unraisable_exception() now also removes its 'unraisable' attribute at the context manager exit.
@tirkarthi @graingert: Would you mind to review the updated PR? |
@graingert: Thanks for your very good feedback, it's very valuable! |
…GH-13554) catch_unraisable_exception() now also removes its 'unraisable' attribute at the context manager exit.
catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.
https://bugs.python.org/issue36829