[IronPython] Traceback Stack Bugs

Haibo Luo haiboluo at exchange.microsoft.com
Sat Jan 6 02:01:26 CET 2007


This is related to http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=2912. We are currently working on it.

Thanks for reporting this.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Friday, January 05, 2007 4:58 PM
To: Discussion of IronPython
Subject: [IronPython] Traceback Stack Bugs

Hello team,

Whilst optimising Resolver we discovered a bug in the handling of
traceback objects with IronPython.

The following code behaves differently under IronPython and CPython :

import sys
def extract_tb():
     tb = sys.exc_info()[2]
     stackInfo = []
     while tb:
         f = tb.tb_frame
         lineno = tb.tb_lineno
         co = f.f_code
         filename = co.co_filename
         stackInfo.append((filename, lineno))
         tb = tb.tb_next
     return stackInfo

try:
     raise ValueError('stuff')
except:
     print extract_tb()

try:
     raise ValueError('stuff')
except:
     print extract_tb()


Under IronPython :

[]
[]


Under CPython :

[('C:\\Python Projects\\modules in
progress\\ironpython\\tracebackBug.py', 15)]
[('C:\\Python Projects\\modules in
progress\\ironpython\\tracebackBug.py', 20)]

If you exec a compiled code object which raises an exception (instead of
directly raising the error) the CPython traceback starts with the Python
code, whereas the IronPython traceback starts with the code object and
goes no further back. (So a different bug...)

The bug I was actually trying to expose is that in Resolver we were
finding that the traceback objects were not being cleared out - the
stack (using the extract_tb function above) was getting longer and
longer. Adding an explicit sys.clear_exc() solved our problem, but it
foxed us for a while.

Unfortunately I can't reproduce this bug easily - but you can see that
something screwy is going on.

Michael
http://www.voidspace.org.uk/ironpython/index.shtml
_______________________________________________
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