Opened 11 years ago

Closed 11 years ago

#5560 closed (fixed)

unicode lazy strings don't work on Jython

Reported by: leosoto <leo.soto@…> Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords: jython
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The problem is that on Jython __unicode__ lives on object (just like __str__ ), so assigning the __unicode__ attribute to lazy instances don't work there.

Attachments (1)

lazy_unicode.patch (1022 bytes) - added by leosoto <leo.soto@…> 11 years ago.
Simple patch, works ok on CPython.

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by leosoto <leo.soto@…>

Attachment: lazy_unicode.patch added

Simple patch, works ok on CPython.

comment:1 Changed 11 years ago by James Bennett

Triage Stage: UnreviewedAccepted

comment:2 Changed 11 years ago by leosoto <leo.soto@…>

Well, Jython now dropped object.__unicode__, but a __unicode__ method assigned specifically to an instance doesn't work.

In fact, on CPython it seems that the only __*__ method that works when assigned to an instance is __unicode__ (all the others are looked up on the type, not the instance).

So, this patch still sounds reasonable, as the original code relies on a obscure implementation detail of CPython.

comment:3 Changed 11 years ago by Malcolm Tredinnick

Nice idea. I hadn't realised the significance of creating a new __proxy__ each time. This is much neater than what we're doing in __str__, so I'll change that, too.

comment:4 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [6587]) Fixed #5560 -- Improved the way we create str and unicode methods in
lazy() objects. This fixes things for Jython and makes the code more readable,
even for CPython. Thanks, Leo Soto.

Note: See TracTickets for help on using tickets.
Back to Top