Opened 10 years ago
Last modified 10 years ago
#11509 closed defect
Fragment in PermissionError msg results in TypeError — at Initial Version
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Jun Omae | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
>>> 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
The following patch seems to fix the issue, but I am unsure that it is the correct solution.
-
trac/perm.py
diff --git a/trac/perm.py b/trac/perm.py index 4b514e4..f0f9475 100644
a b class PermissionError(StandardError): 59 59 'operation. You don\'t have the required ' 60 60 'permissions.', perm=self.action) 61 61 elif self.msg: 62 return self.msg62 return unicode(self.msg) 63 63 else: 64 64 return _('Insufficient privileges to perform this operation.') 65 65
Note:
See TracTickets
for help on using tickets.