[IronPython] Getting a call stack from an exception?

Dino Viehland dinov at exchange.microsoft.com
Wed Jul 12 22:46:55 CEST 2006


It shouldn't be too hard to just get the line numbers & filenames - the nice thing that the standard traceback.py file gives you is it can get the lines of source code and include it in the displayed call stack as well.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lee Culver
Sent: Wednesday, July 12, 2006 1:39 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Getting a call stack from an exception?

I'm probably going to just reimplement the functionality in pure IP.  If I get anywhere with it I'll post it up here.

________________________________
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Alex Henderson
Sent: Wednesday, July 12, 2006 1:37 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Getting a call stack from an exception?

I would be interested to know how you get on with this problem Lee - I've got the same issue myself.

Chez,

  - Alex

________________________________
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lee Culver
Sent: Thursday, 13 July 2006 6:57 a.m.
To: Discussion of IronPython
Subject: Re: [IronPython] Getting a call stack from an exception?

Yikes.  I was hoping for a way to do it in pure IronPython.  Thanks though.

________________________________
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Wednesday, July 12, 2006 11:54 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Getting a call stack from an exception?

Tracebacks are the correct way to do this, I recommend you install the standard Python library against IronPython to make this really useful - then you can do import traceback and use its handy functions (otherwise you'll be walking the traceback list in sys.exc_info() which won't be much fun).

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lee Culver
Sent: Wednesday, July 12, 2006 11:49 AM
To: Discussion of IronPython
Subject: [IronPython] Getting a call stack from an exception?

I would like to print out a call stack from an exception object, much like what the IronPython console does when an exception goes uncaught.  I have tried doing something like this:

try:
    ... #something that causes an exception
except Exception, e:
    print e

But, like python, this only prints out the message given to it.  I have also tried this:
    print e.clsException
    print e.clsException.StackTrace

But these print out the stack trace which includes the IronPython library c# code as well.  Is there a way to get the stack trace which only contains the python call stack (like the one the console uses)?

Thanks
-Lee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060712/d07ba897/attachment.html>


More information about the Ironpython-users mailing list