Edgewall Software
Modify

Opened 17 years ago

Closed 16 years ago

#5981 closed defect (fixed)

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

Reported by: Shun-ichi Goto <shunichi.goto@…> Owned by: Christian Boos
Priority: normal Milestone: 0.11.1
Component: general Version: devel
Severity: normal Keywords: i18n unicode
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

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 class TracError(Exception):  
    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 (0)

Change History (5)

comment:1 by hyuga <hyugaricdeau@…>, 16 years ago

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

comment:2 by Christian Boos, 16 years ago

Keywords: unicode added
Milestone: 0.11.1
Owner: changed from Jonas Borgström to Christian Boos

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.

comment:3 by Christian Boos, 16 years ago

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.

comment:4 by Christian Boos, 16 years ago

Milestone: 0.11.20.11.1

Ok for the backport?

comment:5 by Christian Boos, 16 years ago

Resolution: fixed
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.