[IronPython] CP Issue #21659: Subclassing unicode

Michael Foord fuzzyman at voidspace.org.uk
Tue Mar 17 02:01:55 CET 2009


Jeff Hardy wrote:
> Hi,
> Is there any quick workaround for #21569? It's causing about a third
> of the Genshi errors I'm hitting. Trying to override __init__ in the
> subclass gives the same error.
>
> class Foo(unicode):
>     def __init__(self, val):
>         pass
>
> f = Foo(1)
>
> Traceback (most recent call last):
>   File "foo.py", line 5, in __main__
> TypeError: expected str, got int
>   

Wouldn't that particular example bomb out on CPython as well - you need 
to override __new__ on the immutable builtins surely?

Michael
> Thanks,
> Jeff
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


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





More information about the Ironpython-users mailing list