[IronPython] Overriding derived methods

Dino Viehland dinov at exchange.microsoft.com
Tue May 23 05:42:46 CEST 2006


Another message back from the other side of a black hole... sorry for the delay on this.

You're hitting the other side of "in many cases"...  Unfortunately if the other method is called then we'll dispatch to the incorrect method there too...  This is fixed in beta 7 which should be out real soon now.


Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs
Sent: Friday, May 05, 2006 10:19 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Overriding derived methods

Dino Viehland wrote:
> There's a bug in beta 5 and beta 6 where we can sometimes fail to call the correct derived method.  You can work around the bug in many cases w/:
>
> Class MyForm(Form):
>         def __init__(self):
>                 self.OnKeyUp = self.OnKeyUp
>         def OnKeyUp(self, e):
>                 ...
>
> Unfortunately you can still get some erattic behavior w/ the workaround in place.
>
> This will be fixed for our beta 7 release.  This happens only when deriving from a type that has a large number of virtual methods, and unfortunately System.Windows.Forms hits this pretty heavily.

Thanks for the quick response, Dino. I've run into another (rather
bizarre) situation, you'll need a few preliminary steps first:

1.) Create a vanilla "Windows Application" project in Visual Studio (C#
2005 Express Edition, not sure if this matters)
2.) Compile it, add the compiled assembly to somewhere in your path.

I used the following code to reproduce the error:

 >>> clr.AddReferenceToFile('WindowsApplication1.exe')
 >>> from WindowsApplication1 import Form1
 >>> class MyForm(Form1):
...   def __init__(self):
...     self.OnKeyUp = self.OnKeyUp
...   def OnKeyUp(self, e):
...     print e
...
 >>> frm = MyForm()
 >>> Application.Run(frm)

Which yields the following output:

System.Windows.Forms.PaintEventArgs
System.Windows.Forms.KeyEventArgs
etc.

I'm really wondering about the PaintEventArgs object that sneaks in
there. I haven't tried reproducing *all* of the generated C# code in
pure IronPython code yet but the minimal form I mentioned in my previous
email is not subject to this odd behaviour.

Regards
--
Jonathan
_______________________________________________
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