[IronPython] Getting a traceback stack in IronPython 2.0

Dan Eloff dan.eloff at gmail.com
Wed Jan 14 16:34:24 CET 2009


I use this code:

from Microsoft.Scripting.Hosting import ExceptionOperations
from IronPython.Hosting import Python
engine = Python.CreateEngine()
exc_service = engine.GetService[ExceptionOperations]()
traceback = exc_service.FormatException(e.clsException)

-Dan

On Tue, Jan 13, 2009 at 10:43 PM, Laurion Burchall
<laurionb at service.exchange.microsoft.com> wrote:
> I'm upgrading our internal test framework from IronPython 1.X to 2.X.
> Getting a good stack trace from an exception is eluding me. The old code
> looks like this:
>
>    try:
>     # runs the test
>    except Exception, e:
>     failCount += 1
>     PrintTestOutcome(testCount, False, testFullName, e.ToString())
> What is the 2.X equivalent? By default e.ToString() gives the ugly 'real'
> callstack. In a test program e.clsException did the right thing, but that
> only appears sometimg (if System is imported?) and when used in the test
> framework gave the .NET callstack instead of line number in Python scripts.
>
> Any suggestions?
>
> thanks,
> --Laurion
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>



More information about the Ironpython-users mailing list