[IronPython] Django, __unicode__, and #20366

Jeff Hardy jdhardy at gmail.com
Thu Feb 11 18:35:40 CET 2010


On Thu, Feb 11, 2010 at 8:44 AM, Vernon Cole <vernondcole at gmail.com> wrote:
> Just a little reminder in all this noise...
>
> The correct thing to do with unicode(u'a unicode string') is MAKE NO CHANGE.
> The correct thing to do with str('an ASCII string') is MAKE NO CHANGE.

Ah, but it's not string literals we're worried about here - it's
objects that implement __str__ or __unicode__.

class Foo(object):
    def __str__(self):
        return 'Foo str'
    def __unicode__(self):
        return 'Foo unicode'

>>> f = Foo()
>>> str(f)
'Foo str'
>>> unicode(f)
'Foo str'

This is bad for Django.

Besides, u'...' and '...' are identical in IronPython anyway - every
string literal is already unicode.

- Jeff



More information about the Ironpython-users mailing list