[IronPython] Problems defining new classes

Clive Tong Clive_Tong at scientia.com
Fri Aug 13 17:27:50 CEST 2004

I've just started using IronPython, but have problems getting a class deifntion to work:

  class foo: pass

Gives the error

System.Reflection.TargetException: Non-static field requires a target.
  at System.Reflection.RuntimeFieldInfo.InternalGetValue(Object obj, Boolean requiresAccessCheck)
  at System.Reflection.RuntimeFieldInfo.GetValue(Object obj)
  at IronPython.Objects.module.__getattribute__(String name)
  at IronPython.Objects.ModuleDictionary.get_Item(Object key)
  at IronPython.Objects.Frame.GetGlobal(String name)
  at input_0.Run(Frame frame)
  at IronPythonConsole.IronPython.DoInteractive()

The fix seems to be changing the definition of __getattribute__ in objects\module.cs from 
   return fi.GetValue(null);
   return fi.GetValue(this);

Is this the correct fix ?

More information about the Ironpython-users mailing list