Edgewall Software

Opened 10 years ago

Last modified 10 years ago

#11509 closed defect

Fragment in PermissionError msg results in TypeError — at Version 1

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: general Version:
Severity: normal Keywords:
Cc: Jun Omae Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

>>> from genshi.builder import tag
>>> from trac.core import TracError
>>> from trac.perm import PermissionError
>>> from trac.util.translation import tag_
>>> from trac.util.text import to_unicode
>>> e1 = TracError(tag_("This is a %(fragment)s", fragment=tag.em("Fragment")))
>>> to_unicode(e1)
u'This is a <em>Fragment</em>'
>>> e2 = PermissionError(msg=tag_("This is a %(fragment)s", fragment=tag.em("Fragment")))
>>> to_unicode(e2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "trac/util/text.py", line 74, in to_unicode
    return unicode(text)
TypeError: coercing to Unicode: need string or buffer, LazyProxy found

Change History (1)

comment:1 by Ryan J Ollos, 10 years ago

Description: modified (diff)
Milestone: 0.12.61.0.2
Owner: set to Ryan J Ollos
Status: newassigned

The proposed change that led to discovering this issue, as well as a proposed fix, can be found in log:rjollos.git:t11509. If the proposed change looks okay, unit tests for PermissionError should be added and the TracDev/Exceptions#CustomTracExceptions page needs to be updated.

Note: See TracTickets for help on using tickets.