Code

Opened 7 years ago

Closed 6 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: UI/UX:

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

Download all attachments as: .zip

Change History (5)

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

Simple patch, works ok on CPython.

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 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 6 years ago by mtredinnick

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 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.