Opened 17 years ago

Closed 17 years ago

#5560 closed (fixed)

unicode lazy strings don't work on Jython

Reported by: leosoto <leo.soto@…> Owned by: nobody
Component: Uncategorized Version: dev
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

Description

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@…> 17 years ago.
Simple patch, works ok on CPython.

Download all attachments as: .zip

Change History (5)

by leosoto <leo.soto@…>, 17 years ago

Attachment: lazy_unicode.patch added

Simple patch, works ok on CPython.

comment:1 by James Bennett, 17 years ago

Triage Stage: UnreviewedAccepted

comment:2 by leosoto <leo.soto@…>, 17 years ago

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 by Malcolm Tredinnick, 17 years ago

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 by Malcolm Tredinnick, 17 years ago

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