Edgewall Software

Ticket #5981 (closed defect: fixed)

Opened 13 months ago

Last modified 2 months ago

TracException should have `__unicode__()` method for non ASCII message

Reported by: Shun-ichi Goto <shunichi.goto@…> Owned by: cboos
Priority: normal Milestone: 0.11.1
Component: general Version: devel
Severity: normal Keywords: i18n unicode
Cc:

Description

While playing with i18n branch, there's a problem to raise exception with translated message. TracException class should have __unicode__() method to use non-ASCII exception message. Otherwise, we will get UnicodeEncodeError. (Ex., see changeset.py line 878)

  • trac/core.py

    diff -r c0a1d13079de trac/core.py
    a b  
    3737        if title: 
    3838            self.title = title 
    3939        self.show_traceback = show_traceback 
     40         
     41    def __unicode__(self): 
     42        return unicode(self.message) 
    4043 
    4144 
    4245class Interface(object): 

This issue is realized on i18n branch code, but 0.11-dev trunk code has also.

Attachments

Change History

Changed 8 months ago by hyuga <hyugaricdeau@…>

I second this--I just ran into the same problem. It's an easy fix, and should be included in 0.11.

Changed 6 months ago by cboos

  • keywords unicode added
  • owner changed from jonas to cboos
  • milestone set to 0.11.1

Well, this unicode(self.message) won't work if self.message itself is not already convertible to unicode, but I guess that would be yet another problem.

So actually the patch looks good.

Changed 5 months ago by cboos

Committed in r6984 (on the i18n branch as well, where the reporter discovered the issue and where I was able to reproduce it).

Should land on trunk when the branch gets merged.

I think it can be backported to 0.11-stable as well.

Changed 3 months ago by cboos

  • milestone changed from 0.11.2 to 0.11.1

Ok for the backport?

Changed 2 months ago by cboos

  • status changed from new to closed
  • resolution set to fixed

Committed as [7397] on 0.11-stable. Thanks for the patch!

Add/Change #5981 (TracException should have `__unicode__()` method for non ASCII message)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.