-
-
Notifications
You must be signed in to change notification settings - Fork 70
Fix issue where pytestqt was hiding the information when there's an exception raised from another exception on Python 3 #168
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
Conversation
pytestqt/exceptions.py
Outdated
| from io import StringIO | ||
| import traceback | ||
| s = StringIO() | ||
| traceback.print_exception(type_, value, tback, file=s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not format_tb as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format_tb hides information on the cause of another exception (so, if an exception is raised from another exception, the cause is lost).
2 similar comments
pytestqt/exceptions.py
Outdated
| if sys.version_info[0] > 2: | ||
| from io import StringIO | ||
| s = StringIO() | ||
| traceback.print_exception(type_, value, tback, file=s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - I misread the code - why not format_exception?
|
You pushed while I was reviewing, but what I said is still valid 😉 |
|
Agreed. format_exception seems better (and should work on both py2 and py3). Just submitted the change (sorry for the multiple commits -- I was too lazy to download it locally as I have just a conda installed version locally and just did it on the github ui... I think that on apply you can squash it all on a single commit). |
…xception raised from another exception on Python 3
|
Thanks @fabioz, squashed and rebased on Anything else here @The-Compiler? Otherwise I think we can cut a |
|
I kinda forgot about this, but I think it's fine. |
This change makes a change to use print_exception instead of rolling your own when on Python 3. I've done the change on the fly here, so, it may need better tests on Python 3 (and alternatively, the same could be used on Python 2, but in that case io.StringIO may not work and may need StringIO.StringIO).