Skip to content
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

Support Python 3's 'raise Exception from e'? #19

Open
dsully opened this issue May 24, 2018 · 5 comments
Open

Support Python 3's 'raise Exception from e'? #19

dsully opened this issue May 24, 2018 · 5 comments

Comments

@dsully
Copy link

dsully commented May 24, 2018

It's not clear if tbvaccine supports Python 3's 'raise MyException from e' syntax.

Or at least the original exception is not being emitted in the tbvaccine output.

@skorokithakis
Copy link
Owner

Hmm yes, you're right, currently we're printing the last stack frame. This needs to be changed so TBV is more intelligent about which frame it prints.

@alexmojaki
Copy link

more intelligent about which frame it prints.

Surely it should print them all?

@skorokithakis
Copy link
Owner

It shouldn't expand frames that aren't a part of your program, and doesn't currently.

@alexmojaki
Copy link

Let me be clearer. Consider this script:

try:
    1 / 0
except:
    foo

By default it outputs:

Traceback (most recent call last):
  File "/home/alex/.config/JetBrains/PyCharm2020.2/scratches/scratch_856.py", line 6, in <module>
    1 / 0
ZeroDivisionError: division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/.config/JetBrains/PyCharm2020.2/scratches/scratch_856.py", line 8, in <module>
    foo
NameError: name 'foo' is not defined

This contains two tracebacks. Previously it sounded like you were referring to tracebacks as frames, so I just went with it. Each traceback here contains one frame.

tbvaccine only shows the last traceback:

Traceback (most recent call last):
  File "/home/alex/.config/JetBrains/PyCharm2020.2/scratches/scratch_856.py", line 8, in <module>
>   foo
NameError: name 'foo' is not defined

Presumably tbvaccine should print every traceback so that users know what went wrong, although it can be selective about which frames it prints/expands within each traceback.

Also note that this example doesn't use the raise from syntax.

@skorokithakis
Copy link
Owner

Oh, I see. Yes, it definitely shouldn't swallow tracebacks, this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants