0.91 Regression: accessing deep methods?

May 24, 2009 at 6:53 PM

Testing 0.91 as "IronPython 2.6 Beta (2.6.0.1) on .NET 2.0.50727.3053":

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import *
f = Form()
f.SetStyle(ControlStyles.UserPaint, True)

This gives the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot access protected member SetStyle without a python subclass of
Control

I can see the method SetStyle, but it is always reported as protected. This worked in 0.90. f.Show() works, so maybe this is caused by SetStyle being a more primitive method of Control?

Thanks for work-arounds, or other pointers.

-Doug

Coordinator
May 24, 2009 at 7:05 PM

That was actually a bug fix in IronPython – in some cases we were allowing you to call protected members on normal .NET classes and now we no longer allow that. 

The work around for this would be to derive from form:

class MyForm(Form): pass

f = MyForm()

f.SetStyle(ControlStyles.UserPaint, True)

From: dsblank [mailto:notifications@codeplex.com]
Sent: Sunday, May 24, 2009 10:54 AM
To: Dino Viehland
Subject: 0.91 Regression: accessing deep methods? [dlr:57324]

From: dsblank

Testing 0.91 as "IronPython 2.6 Beta (2.6.0.1) on .NET 2.0.50727.3053":

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import *
f = Form()
f.SetStyle(ControlStyles.UserPaint, True)

This gives the error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot access protected member SetStyle without a python subclass of
Control

I can see the method SetStyle, but it is always reported as protected. This worked in 0.90. f.Show() works, so maybe this is caused by SetStyle being a more primitive method of Control?

Thanks for work-arounds, or other pointers.

-Doug

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

May 24, 2009 at 8:53 PM

Thanks! That clears it up under .NET, but reveals a Mono bug apparently...

 

May 26, 2009 at 12:04 PM
Perhaps a Mono/.NET difference:

"""
The only difference in visibility on Control::SetStyle is that on .net it's
Family and on Mono it's FamilyOrAssembly which is perfectly fine.
...
FamilyOrAssembly visibility implies Family.
"""

Could it be that this is causing the issue? Is Mono wrong, that Control::SetStyle must be Family? Or should FamilyOrAssembly is OK, and IronPython should allow it?

Thanks for any feedback!

See full bug report:

https://bugzilla.novell.com/show_bug.cgi?id=506882
May 26, 2009 at 1:10 PM

This sounds like a bug in IronPython. There are two places in NewTypeMaker.cs where we check for IsFamily but not for IsFamilyOrAssembly, and I think the place in OverrideBaseMethod could be causing this.

Please file a bug on the IronPython CodePlex site: http://ironpython.codeplex.com/WorkItem/List.aspx

May 26, 2009 at 1:24 PM

Thanks! Followups to:

http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=22723