[IronPython] Django, __unicode__, and #20366

Jeff Hardy jdhardy at gmail.com
Tue Feb 16 00:11:54 CET 2010


I found one more issue:

class Foo(object):
    def __unicode__(self):
        return 'uFoo'

print 'Foo: %s' % Foo()
print u'Foo: %s' % Foo()

>python test_u.py
Foo: <__main__.Foo object at 0x003E8370>
Foo: uFoo

>ipy.exe test_u.py
Foo: <Foo object at 0x000000000000002B>
Foo: <Foo object at 0x000000000000002C>

See http://docs.python.org/library/stdtypes.html#string-formatting-operations
(esp. note 6) for reference.

- Jeff

On Mon, Feb 15, 2010 at 10:49 AM, Dino Viehland <dinov at microsoft.com> wrote:
> This is now checked into the Main branch if anyone wants to download, compile, and give it a shot.
>
> I'll push it to the 2.6 branch post-PyCon.
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Friday, February 12, 2010 2:24 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] Django, __unicode__, and #20366
>
> On 12/02/2010 03:37, Dino Viehland wrote:
>> And it turns out this works great!  We now pass all of the tests in
>> test_str and test_unicode related to calling str/unicode and getting
>> the appropriate __str__/__unicode__ method called.  We also now properly
>> don't decode strings when you do unicode('foo') so we no longer throw
>> for Vernon's exception case where CPython doesn't throw.
>>
>> So I'm inclined to go with this fix.
>>
>
> That's great news.
>
> Michael
>>
>>> -----Original Message-----
>>> From: users-bounces at lists.ironpython.com [mailto:users-
>>> bounces at lists.ironpython.com] On Behalf Of Dino Viehland
>>> Sent: Wednesday, February 10, 2010 9:38 AM
>>> To: Discussion of IronPython
>>> Subject: Re: [IronPython] Django, __unicode__, and #20366
>>>
>>> It definitely won't be in 2.6RC1 but could be in 2.6 final (or RC2 or
>>> whatever).
>>>
>>> I'm still looking into Michael's proposed fix of recognizing calls to
>>> unicode -
>>> it's a little tricky dealing with * and **args calls to it and I got
>>> distracted
>>> by preparing for PyCon.
>>>
>>> Hopefully I can finish that up in the next couple of days and see how
>>> that
>>> works vs. just calling __unicode__ when __str__ gets called.
>>>
>>>
>>>> -----Original Message-----
>>>> From: users-bounces at lists.ironpython.com [mailto:users-
>>>> bounces at lists.ironpython.com] On Behalf Of Jeff Hardy
>>>> Sent: Wednesday, February 10, 2010 9:21 AM
>>>> To: Discussion of IronPython
>>>> Subject: Re: [IronPython] Django, __unicode__, and #20366
>>>>
>>>> On Mon, Feb 1, 2010 at 2:46 PM, Dino Viehland<dinov at microsoft.com>
>>>>
>>> wrote:
>>>
>>>>> Messing with identity starts to get really scary and I'd rather not
>>>>>
>>> go
>>>
>>>>> there - I'm sure there will be lots of edge cases which will be
>>>>>
>>> broken.
>>>
>>>>> I could see is making unicode(foo) do something different.  If you
>>>>>
>>> aliased
>>>
>>>>> unicode then you'd get str's behavior though but that might be
>>>>>
>>> perfectly
>>>
>>>>> acceptable.  It's definitely a solution I had not considered and
>>>>>
>>> it'd
>>>
>>>>> probably fix multiple issues.
>>>>>
>>>> Hi Dino,
>>>> It looks like this is a major impediment to running Django; the
>>>> majority of the test suite failures are because IronPython calls
>>>> __str__ instead of __unicode__. Any chance this could be fixed for
>>>> 2.6.1? I know it's a big change, but IMHO it's pretty critical as
>>>> well.
>>>>
>>>> - Jeff
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.ironpython.com
>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.ironpython.com
>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>
>> _______________________________________________
>> 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
>
> READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> 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