8000 bpo-36829: Document test.support.catch_unraisable_exception() by vstinner · Pull Request #13554 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
May 24, 2019
Merged

bpo-36829: Document test.support.catch_unraisable_exception() #13554

merged 1 commit into from
May 24, 2019

Conversation

vstinner
Copy link
Member
@vstinner vstinner commented May 24, 2019

catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.

https://bugs.python.org/issue36829

@vstinner
Copy link
Member Author

cc @tirkarthi @graingert

Usage::

with support.catch_unraisable_exception() as cm:
# code creating an "unraisable exception"
Copy link
Contributor

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()

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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!

@vstinner
Copy link
Member Author

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.
@vstinner
Copy link
Member Author

@tirkarthi @graingert: Would you mind to review the updated PR?

@vstinner vstinner merged commit 6dbbe74 into python:master May 24, 2019
@vstinner
Copy link
Member Author

@graingert: Thanks for your very good feedback, it's very valuable!

@vstinner vstinner deleted the catch_unraisable2 branch May 24, 2019 22:09
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…GH-13554)

catch_unraisable_exception() now also removes its 'unraisable'
attribute at the context manager exit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0