[issue30384] traceback.TracebackException.format shouldn't format_exc_only() when __traceback__ is None

Aaron Meurer report at bugs.python.org
Wed Nov 4 16:02:50 EST 2020


Aaron Meurer <asmeurer at gmail.com> added the comment:

I think I found another way to achieve what I was trying to do, which is why I never pursued this. But I still think it's a bug.

__traceback__ = None isn't documented anywhere that I could find, so I was only able to deduce how it should work from reading the source code. If it is documented somewhere let me know.

I admit my initial report is a bit unclear. If you play with the test.py you can see what is going on

    import traceback

    try:
        raise ValueError
    except Exception as e:
        e.__traceback__ = None
        try:
            raise TypeError
        except:
            traceback.print_exc()

produces this output:


    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

My goal is to completely hide the caught exception in the traceback printed from the traceback module. It seems odd that it hides everything except for the actual ValueError.

----------
status: pending -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30384>
_______________________________________


More information about the Python-bugs-list mailing list