Skip to content

Conversation

@fabioz
Copy link
Contributor

@fabioz fabioz commented Feb 21, 2017

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).

from io import StringIO
import traceback
s = StringIO()
traceback.print_exception(type_, value, tback, file=s)
Copy link
Member

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?

Copy link
Contributor Author

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).

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.0%) to 97.041% when pulling bcf5357 on fabioz:patch-1 into 0ab0e8b on pytest-dev:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-3.0%) to 97.041% when pulling bcf5357 on fabioz:patch-1 into 0ab0e8b on pytest-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.0%) to 97.041% when pulling bcf5357 on fabioz:patch-1 into 0ab0e8b on pytest-dev:master.

if sys.version_info[0] > 2:
from io import StringIO
s = StringIO()
traceback.print_exception(type_, value, tback, file=s)
Copy link
Member

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?

@The-Compiler
Copy link
Member

You pushed while I was reviewing, but what I said is still valid 😉

@coveralls
Copy link

coveralls commented Feb 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling fa19dcd on fabioz:patch-1 into 0ab0e8b on pytest-dev:master.

@fabioz
Copy link
Contributor Author

fabioz commented Feb 21, 2017

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).

@coveralls
Copy link

coveralls commented Feb 21, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 2a1504a on fabioz:patch-1 into 0ab0e8b on pytest-dev:master.

…xception raised from another exception on Python 3
@nicoddemus
Copy link
Member

Thanks @fabioz, squashed and rebased on master.

Anything else here @The-Compiler? Otherwise I think we can cut a 2.1.2 release.

@coveralls
Copy link

coveralls commented Jul 12, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling c89dda4 on fabioz:patch-1 into 1d10f8a on pytest-dev:master.

@The-Compiler
Copy link
Member

I kinda forgot about this, but I think it's fine.

@nicoddemus nicoddemus merged commit ed7a0ed into pytest-dev:master Jul 12, 2017
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

Successfully merging this pull request may close these issues.

4 participants