IMHO this would better be solved upstream. * IPython input transformers should also keep a map from the original source lines to the transformed lines. By default, that would just be the identity map.
* IPython already hooks into the linecache used for tracebacks in get_ipython().compile.cache, just store the original source together with the transformed source and line mapping. Probably that can just be added at the end of the cache tuple. * IPython already hooks into the exception formatting to colorize the exceptions, this should always show the pre-transformed source. On Friday, November 21, 2014 6:45:32 AM UTC, Jeroen Demeyer wrote: > > Hello, > > I have a working proof-of-concept to improve tracebacks for preparsed > code and for Cython code. On http://trac.sagemath.org/ticket/71, you can > see an example of a new traceback. > > This isn't a finished patch yet, but I would like some opinions on the > general approach first. > > > The main changes are: > 1) Change the preparser to add the unpreparsed source as comments. Yes, > this increases the size of preparsed code a lot: > > sage: preparse('2 + 3') > 'Integer(2) + Integer(3) #sage_pp#:2 + 3' > > 2) When executing load() or attach(), always save the preparsed source > to a temporary file. This is needed to get any traceback at all for this > exec()ed code. > > 3) Add an upstream patch to IPython (which is likely to be accepted > upstream, I asked ipython-dev) to not replace the .pyx file by the .so > file in tracebacks. > > 4) Write a custom extract_tb() function which undoes preparsing in > tracebacks and which makes paths absolute w.r.t. SAGE_SRC. The latter is > needed because Cython filenames in tracebacks are relative. > > 5) Monkey-patch the Python library function traceback.extract_tb() with > this custom function when the SageTerminalApp starts. > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.