-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-46328: added sys.exception() #30514
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
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.
Please document the new function in Doc/whatsnew/3.11.rst.
Python/sysmodule.c
Outdated
@@ -2457,6 +2480,7 @@ Functions:\n\ | |||
\n\ | |||
displayhook() -- print an object to the screen, and save it in builtins._\n\ | |||
excepthook() -- print an exception and its traceback to sys.stderr\n\ | |||
exception() -- return the current exception (thread safe)\n\ |
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.
What is this "(thread safe)" note? It's not mentioned anywhere else.
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.
The next line for exc_info mentions it's thread-safe, so I didn't want it to look like this isn't. But maybe I should remove it from both lines?
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.
My concern is more that it's only in help(sys), but nowhere else. If it's thread safe and this information matters, it should be in the documentation as well. Maybe also in the function docstring.
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.
I don’t know if it matters. This info is thread specific anyway, so you would assume this is thread safe (this is mentioned in the doc).
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.
Are the other functions in sys, like getrefcount, not thread safe?
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.
I think it could be that the intention in the help line for exc_info was to say that it’s a thread-specific value, but it was worded incorrectly. I’d change both to say this instead of thread-safe.
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.
Most functions implemented in C are thread-safe. I agree, remove the mention from both functions.
The exact behavior can be elaborated in the documentation, if needed.
Yeah, the current exception is per-thread.
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.
LGTM. But I suggest to remove "(thread safe)" from sys docstring.
Nice @iritkatriel! That looks like an useful feature ;-) I dislike |
https://bugs.python.org/issue46328