New submission from Aaron Meurer:
I'm trying to completely hide an exception from the traceback module. From
reading the source, it looks like the only way to do this is to set
__traceback__ to None (I can also set __suppress_context__ to True, but that
only works if I have another exception higher up in the context chain).
However, this still prints the traceback itself, and the line for SyntaxErrors.
Consider the attached test.py. It outputs
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 8, in <module>
raise TypeError
TypeError
File "<string>", line 1
a b
^
SyntaxError: unexpected EOF while parsing
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 19, in <module>
raise TypeError
TypeError
I suppose it should also not print the "During handling of the above exception,
another exception occurred:" part.
----------
components: Library (Lib)
files: test.py
messages: 293837
nosy: Aaron.Meurer
priority: normal
severity: normal
status: open
title: traceback.TracebackException.format shouldn't format_exc_only() when
__traceback__ is None
Added file: http://bugs.python.org/file46867/test.py
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue30384>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com