-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-44279: [doc] reword contextlib.suppress documentation #26428
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
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
I don't follow. It will suppress DeprecationWarning if you raise it:
|
@iritkatriel I think per the doc of warnings, the typical way of issuing warnings is through the >>> import contextlib, warnings
>>> with contextlib.suppress(DeprecationWarning):
... warnings.warn("Something is deprecated", DeprecationWarning)
...
<stdin>:2: DeprecationWarning: Something is deprecated
>>> |
That's correct, so the exception is not raised. The documentation states that suppress is equivalent to try: ... except: pass. That wouldn't suppress a warning.warn() either. warnings has its own suppression api: https://docs.python.org/3/library/warnings.html#temporarily-suppressing-warnings Perhaps it would be clearer if in the first sentence it said "exceptions if they are raised in the body" instead of "exceptions if they occur in the body". |
@iritkatriel Yes, that makes more sense. Now that we are settled that this pull request is not suitable, I would close it. Thank you for the kind reply! |
Would you like to create a new one changing "if they occur" to "if they are raised"? |
@iritkatriel I would like to but my signed CLA is still long waiting to get processed. The waiting is a bit tedious. So I think perhaps it's better you just change it directly with no PR. After all, the change is brought up by you, and I don't want to take the credit. Thanks! |
The CLA shouldn't take a long time. Are you sure you linked your bugs.python.org account with your github account correctly? |
Also, you don't need a new PR. We can reopen this one and replace the change. |
I re-checked the b.p.o. account, the email and the signed PDF document. Yes it should be correct. On second thought, I did not write a very detailed address on the CLA form out of privacy concern; not sure whether that is a problem.
Ok, I am doing it. |
@Mariatta Are you able to check what's happening with the CLA? If it's not you, then who can? |
…xceptions, but not warnings issued by warnings.warn()
@iritkatriel Thanks for the help. The system finally confirms that I have signed the CLA. Everything is set and the PR is ready to get merged. Anytime when you are okay. |
I notice that there are some hyperlinks in the contextlib.rst that look like the following: :keyword:`!with` with an additional exclamation mark. It this normal? Got to admit that I am not very familiar with the reStructuredText syntax. |
If you add ! then it's not a link, just a different font. See here: |
Maybe in this case it makes sense to put !s, because this whole doc is about context managers so a lot of links to |
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.
You can just click the button to accept these changes in your PR.
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Thanks for the information and tips. I was not very familiar with the GitHub web UI. Your suggested changes are done, through the web UI. |
…honGH-26428) (cherry picked from commit 87272b7) Co-authored-by: MapleCCC <littlelittlemaple@gmail.com>
GH-26480 is a backport of this pull request to the 3.10 branch. |
…onGH-26428) (cherry picked from commit 87272b7) Co-authored-by: MapleCCC <littlelittlemaple@gmail.com>
GH-26481 is a backport of this pull request to the 3.9 branch. |
Thank you @MapleCCC , welcome to CPython! |
@iritkatriel Oh, thank you! I learned a lot. Happy that the PR goes well. 🎉 |
The document of
contextlib.suppress
does make it sound like it would suppress any specified exception. It would be better if we inform the user that the overarching promise doesn't include warnings, which are also exceptions, albeit special.https://bugs.python.org/issue44279