[IronPython] Odd tracebacks

Dan Eloff dan.eloff at gmail.com
Mon Jan 5 18:12:07 CET 2009


On Fri, Jan 2, 2009 at 12:33 PM, Dino Viehland <dinov at microsoft.com> wrote:
> Are there other exceptions being thrown, potentially somewhere on the stack below game\models\__init__.py on line 144?  Maybe we're calling a built-in function somewhere that's calling back into your code and is doing something funky with the exception tracking.  Can you run this under VS and get the stack traces where all the exceptions are being thrown leading up to the problem?
>

Sorry I took so long to get back to you.

Here is a similar error that I created in an easier to debug place.
This is looking very much more like a bug now, note the CLR stack
trace seems correct, but the python stack trace is crazy. This is
silverlight, so it's possible the fault could be in
Microsoft.Scripting.Silverlight's error formatting code. Print
statements at the top of Model.__getattr__ and pairwise show that
neither are called in the process of rasing this error, as the CLR
stack trace confirms.

I ran this under VS, from when I click the button that triggers the
error, here's what happens in order:

an AttributeError at __getattr__ in beskar\namespace.py, line 47

After pressing Continue:

an AttributeError at __getattr__ in beskar\namespace.py, line 47

Not sure why it seems to be raised twice in a row like that, the print
statement right above raise is executed only once, do you know why?
Call stack for both (only addresses change):

Snippets.debug.scripting!S$34.__getattr__$686(object self, object attr
= "BuildList") Line 47 + 0x184 bytes
[External Code]	
Snippets.debug.scripting!S$38.__getattr__$776(object self, object attr
= "BuildList") Line 37 + 0x107 bytes	 	[External Code]
Snippets.debug.scripting!S$35.LoadXaml$738(object self) Line 51 + 0x3ac bytes
[External Code]	
Snippets.debug.scripting!S$74.OnCreateBuildOrder$1693(object self,
object sender = {System.Windows.Controls.Button}, object e =
{System.Windows.RoutedEventArgs}) Line 166 + 0x204 bytes	 	[External
Code]

Pressing Continue simply lets me watch the stack unwind, pausing
around the end of each of the other three methods in the call stack,
and then silverlight displays the error.

In case it is relevant, the method in beskar\namespace.py:

   def __getattr__(self, attr):
        for d in self._dicts:
            if attr in d:
                return d[attr]

        print 'AttributeError %s' % attr
        raise AttributeError(attr)

And the method in beskar\context.py:

    def __getattr__(self, attr):
        v = Namespace.__getattr__(self, attr)
        if utils.requires_context(v):
            return types.MethodType(v, self)
        else:
            return v

Traceback as displayed in silverlight:

AttributeError: BuildList

game\models\__init__.py
Line 143:                         return FACTIONS.reverse_lookup_title(side)
Line 144:
Line 145:                 raise AttributeError(attr)
Line 146:         else:
Line 147:             if SERVER and isinstance(v, list):

at __getattr__ in game\models\__init__.py, line 145
at pairwise in game/utils\functions.py, line 46
at __getattr__ in game\models\__init__.py, line 145
at pairwise in game/utils\functions.py, line 46
at pairwise in game/utils\functions.py, line 46
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in game\models\__init__.py, line 145
at __getattr__ in beskar\namespace.py, line 47   <----- First
exception thrown here (explicit raise AttributeError)
at __getattr__ in beskar\context.py, line 37
at init16 in <string>, line 49
at LoadXaml in beskar\output.py, line 51
at OnCreateBuildOrder in game\planet.py, line 166
CLR Stack Trace:
   at S$34.__getattr__$757(Closure , Object self, Object attr)
   at _stub_$163##135(Closure , CallSite , CodeContext , Object ,
Object , Object )
   at _stub_$2230##942(Closure , CallSite , CodeContext , Object ,
Object , Object )
   at S$39.__getattr__$826(Closure , Object self, Object attr)
   at _stub_$1710##493(Closure , CallSite , CodeContext , Object ,
Object , String )
   at _stub_$1709##492(Closure , CallSite , CodeContext , Object , String )
   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2)
   at _stub_$3474##2131(Closure , CallSite , Object , CodeContext )
   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1)
   at init16$2925##1582(Closure , Object )
   at _stub_$2149##861(Closure , CallSite , Object , Object )
   at Microsoft.Scripting.Runtime.DynamicOperations.Invoke(Object obj,
Object[] parameters)
   at Microsoft.Scripting.Hosting.ObjectOperations.Call(Object obj,
Object[] parameters)
   at BeskarNET.Python.Call(Object callable, Object[] args)
   at BeskarNET.BeskarRuntime.Init(FrameworkElement el, String id)
   at BeskarNET.Beskar.Load(Object obj, BeskarRuntime runtime)
   at BeskarNET.Beskar.LoadXaml(String xaml, Object context, Beskar beskar)
   at _stub_$2146##858(Closure , CallSite , CodeContext , Object ,
Object , Object , Object )
   at S$37.LoadXaml$809(Closure , Object self)
   at _stub_$3343##2000(Closure , CallSite , CodeContext , Object , Object )
   at _stub_$54##26(Closure , CallSite , CodeContext , Object )
   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1)
   at S$74.OnCreateBuildOrder$1769(Closure , Object self, Object
sender, Object e)
   at _stub_$3457##2114(Closure , CallSite , CodeContext , Object ,
Object , Object , Object )
   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
   at _stub_$3456##2113(Closure , CallSite , Object , Object , Object )
   at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2)
   at _stub_$2787##1496(Closure , CallSite , Object , Object , Object )
   at System.Void(Object, Object)(Object[] , Object , Object )
   at BeskarNET.EventGroup.Repeat(Object sender, Object e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs
e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control
ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr
unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

Thanks,
-Dan



More information about the Ironpython-users mailing list