-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Display full tracebacks when an error occurs asynchronously #51566
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
Comments
When an exception is raised in a __del__ method or a finalizer (i.e. a |
Seconded. Is there an already existing flag that could control this behaviour? |
Amaury asks: "Is there an already existing flag that could control this behaviour?" I wonder if the warnings module could be used. |
Submitting a patch proposing this format: -----BEGIN UNRAISABLE EXCEPTION----- Class: AttributeError
Instance: "'NoneType' object has no attribute 'someattr'"
Function: <bound method A.__del__ of <__main__.A object at 0x1007671d0>>
Traceback (most recent call last):
File "/tmp/bla.py", line 4, in __del__
None.someattr
-----END UNRAISABLE EXCEPTION I've wrapped the exception information with header/footer differentiating it from a user's error handling code that also prints tracebacks (is it too much?). I've considered using the warnings module, But I dislike the suppression of already warned messages. (2 instances will raise exception in __del__ but only one message will be printed) This is my first patch submission so feel free giving me a hard time. |
The formatting isn't very conventional for Python. Why not use the normal format? i.e.
Traceback (most recent call last):
File "/tmp/bla.py", line 4, in __del__
None.someattr
AttributeError: 'NoneType' object has no attribute 'someattr' Why is this more likely to get confused with user input than other unhandled exceptions? If you ARE going to deviate, it may be helpful to have it explain why this exception wasn't caught through the normal channels. Maybe the last line could be: "Failed to raise this exception in __del__/finalizer method." or similar. |
Here's the next attempt (took your advice about the convention): Exception ignored in: <bound method A.__del__ of <__main__.A object at 0x1007671d0>>
Traceback (most recent call last):
File "/tmp/bla.py", line 4, in __del__
None.someattr
AttributeError: 'NoneType' object has no attribute 'someattr' reminder of the current format for comparison: Exception AttributeError: "'NoneType' object has no attribute 'someattr'" in <bound method A.__del__ of <main.A object at 0x1007671d0>> ignored I thought about a more elaborate explanation than "Exception ignored" but grepping this function through the code shows it can be called from various places making it too generic. The reason I wanted to add a header/footer is for stating the message and the traceback go together (I print tracebacks to screen all the time), but it might be TMI.. |
I wish there was a less instrusive of saying "+1. I'm happy. Thanks." than posting a whole comment, but until then: +1. I'm happy. Thanks. (I haven't inspected the code - just based on the description.) |
how does one get his patch reviewed? (it's been 6 months) |
Oops, sorry for the silence, I had forgotten about this issue. I'll take a look at the patch soon. |
Hi Antoine, can you please have a look at the patch? It's been over a year since it's submitted. (-: thanks! |
Updated test case for traceback printing, fixed test_cmd_line crashing with new ignored exception message formatting (test was based on regular expression). Patch is attached. |
New changeset a281604a5c9a by Andrew Svetlov in branch 'default': |
Committed. Thanks, guys! |
Note: 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: