On Thursday, January 9, 2014 5:16:57 PM UTC+1, Tom wrote:
>
> I could look at doing this with bpython-curtsies, but if all you want is 
> colorized stack traces, capturing all output as bpython-curtsies does might 
> be too heavy - you change how stack traces are printed somewhere, it's some 
> handler in sys or traceback.
>
> Right now running a script with bpython just uses the normal python 
> executable, but it could be made to run after some shimming to get more 
> bpython-like stack traces...
>

Take a look at 
https://pypi.python.org/pypi/xtraceback/<https://pypi.python.org/pypi/xtraceback/0.2>
 which 
I mentioned above.
What xtraceback lib probably does under the hoods is to use sys.exc_info() 
or something in order to intercept all exceptions and override their 
rendering.
You can enable colored tracebacks by invoking xtraceback at the top of the 
module, like this:

# foo.py
import xtraceback
xtraceback.stdlibcompat.StdlibCompat().install()
1 / 0

I was wondering whether it is acceptable for bpython to do the same either 
by default or via a cmdline option.
The gain in terms of readability, IMO, is enormous.
Assuming xtraceback module is mature enough it might even be used as a 
third party dep for bpython, but of course that's up to the author to 
decide.

-- 
You received this message because you are subscribed to the Google Groups 
"bpython" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bpython.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to