Ryan, The reason you're seeing that weird error message is that consumer versions of Silverlight omit exception strings (note the error says "debugging string" are unavailable, not line numbers =P). The developer version of Silverlight has full exception strings.
Now I can get the line number from sys.exc_info()[2].tb_lineno: >>> try: ... raise Exception() ... except Exception as ex: ... t, v, b = sys.exc_info() ... >>> b <traceback object at 0x000000000000002B> >>> dir(b) ['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next'] >>> b.tb_lineno 2 But calling frame.tb_frame.f_lineno does throw a valid exception: >>> b.tb_frame <frame object at 0x000000000000002C> >>> dir(b.tb_frame) ['Equals', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'f_back', 'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_globals', 'f_lineno', 'f_locals', 'f_restricted', 'f_trace'] >>> b.tb_frame.f_lineno Traceback (most recent call last): at <module> in <string>, line 0 IOError: [Errno 2] Could not load file or assembly 'Microsoft.Scripting.Debugging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Yup, that assembly isn't included in the dlr.xap file today; but it should be. However, on the desktop CLR, it doesn't look accurate: >>> b.tb_frame.f_lineno 1 Dino, thoughts on this? ~js -----Original Message----- From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Ryan Berdeen Sent: Sunday, March 21, 2010 2:39 PM To: users@lists.ironpython.com Subject: [IronPython] IronPython exception line numbers in Gestalt I've just started trying to use Gestalt/dlr.js. I have a simple test script (js.py), which throws an exception, then tries to extract a line number from the exception. --------- import sys def b(): try: raise Exception() except Exception as ex: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() return exceptionTraceback.tb_frame.f_lineno def a(): return b() a() --------- When run in my browser, this fails, and displays this error: --------- IOError: [Errno 2] Error 0x1A88. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.0.50106.0&File=mscorrc.dll&Key=0x1A88 js.py Line 6: except Exception as ex: Line 7: exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() Line 8: return exceptionTraceback.tb_frame.f_lineno Line 9: Line 10: def a(): IOError at b in js.py, line 8 at a in js.py, line 11 at <module> in js.py, line 13 --------- This appears to be a message telling me that line numbers are unavailable which, paradoxically, includes all of the line numbers. Looking through the DLR source, I see it is getting the line number from a DynamicStackFrame (http://dlr.codeplex.com/sourcecontrol/network/Show?projectName=dlr&changeSetId=45843#580636), but I don't see how to get this information from Python. I've tried setting DLR.settings.debug to true, without any effect. What is the correct way to enable resource strings so that they are are accessible from Python, or what else could I do to access them? Thanks, Ryan _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com