[IPython-dev] Nicer display of exceptions with ipython1

Brian Granger ellisonbg.net@gmail....
Sun Jul 20 18:47:35 CDT 2008


>> I am not sure if it is possible, but I think the best solution is if
>> the traceback_trap can be smart and dynamically modify the traceback
>> to remove the unwanted information.  This is also needed even if the
>> interpreter is not raising the exception.  In that case, the
>> interpreter returns a dict that has the traceback as a string - with
>> the unwanted info as well.  Conclusion:  we need to figure out a way
>> of remove the unwanted info in the first place.
>
> Hum, I thought that if you catched the exception in the very function
> where the exec call lies, like it is done in ipython0 (iplib.py, line
> 2083), this give you a cleaner traceback with no postprocessing required.
> However, there must be an additional trick that ipython0 plays. It seems
> that the code is executed in a virtual module. As a result the traceback
> is very clean:
>
> In [7]: print i
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call
> last)
>
> /home/varoquau/<ipython console> in <module>()
>
> NameError: name 'i' is not defined
>
> We need to figure out how this is done. I'll ask Fernando tomorrow.

Sounds good, I think he knows that code much better than I do.

>> Also, isn't this what the callback would have to do anyway?  If so,
>> that logic should just be in the traceback_trap itself.
>
> Well, the callback could do more. In an IDE, for instance, you could have
> an option to open the relevant file in an editor, or open a debugger, or
> a stack inspector. This is why I am thinking of a callback. I can hardly
> see how to account for all these possibilities without either resort to
> some obfuscated code, or using a callback. Maybe I am missing the
> obvious.

Ah, yes, now I see why something like a callback would be nice.  But I
don't think we should do that only instead of figuring out how to get
a nicer traceback.  We should probably do both.

Brian

> Cheers,
>
> Gaël
>


More information about the IPython-dev mailing list