Dan Eloff wrote:
In the 2.1 branch of 43741, it seems there is trouble subclassing a
CLR class that has protected constructors.

# Silverlight Toolkit
import clr
clr.AddReferenceToFile('Microsoft.Windows.Controls.Theming.dll')
from Microsoft.Windows.Controls.Theming import Theme

class MyTheme(Theme):
    def __init__(self):
        raise ValueError

MyTheme()

TypeError: MyTheme() takes at least 2 arguments (1 given)

In fact you can try MyTheme(1,2,3) and get the same error. You can
also not define an __init__ on MyTheme and get the same error.

This would lead me to suspect it's trying the whole time to call the
protected 2 argument constructor, and is ignoring the Python __init__
method. This is a blocker as I've not found any way around it that
will work in silverlight.

Hello Dan,

I can't find this assembly to experiment - but when you subclass a .NET type in IronPython you override the constructor by overriding '__new__' and not '__init__'. Perhaps this is the cause of your problem? (If the default constructor takes two arguments then merely supplying an __init__ method that only takes one won't stop the default two argument constructor being called.)

Michael

By the way, should I should I be using the 2.0 branch rather? I expect
2.1 will be released long before I make my first release, so I thought
that's probably the way to go.

Thanks,
-Dan
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to