-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Add threading.__excepthook__ similar to sys.__excepthook__ #86474
Comments
The sys module contains __excepthook__ to recover sys.excepthook if necessary. The same is not present in the threading module, even if threading.excepthook is exposed. |
Can't you do that in your own hook? For example: orig_hook = threading.excepthook
threading.excepthook = myhook
def myhook(args):
try:
...
except:
print("too bad!")
orig_hook(args) I found one interesting usage of sys.__excepthook__ in code.InteractiveInterpreter: if sys.excepthook is sys.__excepthook__:
lines = traceback.format_exception_only(type, value)
self.write(''.join(lines))
else:
# If someone has set sys.excepthook, we let that take precedence
# over self.write
sys.excepthook(type, value, tb) So it seems like sys.__excepthook__ is useful ;-) |
That is exactly what I wished this was there for hehe. We are installing a custom version of excepthook and wanted to check if the user had changed it. |
PR merged, thanks Mario. |
threading.__excepthook__
#23218Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: