#5575 closed defect (fixed)
[Patch] UnicodeEncodeError on Japanese tag
Reported by: | nac | Owned by: | Michael Renzmann |
---|---|---|---|
Priority: | normal | Component: | TagsPlugin |
Severity: | major | Keywords: | unicode |
Cc: | Trac Release: | 0.11 |
Description
I got UnicodeEncodeError when I clicked Japanese tag in. (Japanese tag itself can be entered and displayed with tag macro like tag cloud.)
Error is
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
Here is traceback;
File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 435, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 205, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-i586/egg/tractags/web_ui.py", line 99, in process_requestFile "build/bdist.linux-i586/egg/tractags/macros.py", line 80, in expand_macroFile "build/bdist.linux-i586/egg/tractags/macros.py", line 80, in <lambda>
And my trac system is
Trac | 0.11.4 |
Python | 2.5.4 (r254:67916, May 24 2009, 15:20:27) [GCC 4.1.2(Gentoo 4.1.2 p1.1)] |
setuptools | 0.6c9 |
SQLite | 3.6.14 |
pysqlite | 2.3.2 |
Genshi | 0.5.1 |
mod_python | 3.3.1 |
Pygments | 1.0 |
jQuery | 1.2.6 |
Attachments (0)
Change History (11)
comment:1 Changed 15 years ago by
comment:2 Changed 14 years ago by
Summary: | UnicodeEncodeError on Japanese tag → [Patch] UnicodeEncodeError on Japanese tag |
---|
comment:3 Changed 14 years ago by
Using to_unicode function can resolve this problem and it will be better than .encode method.
from trac.util.text import to_unicode for resource, tags in sorted(query_result, #key=lambda r: str(r[0].id)): key=lambda r: to_unicode(r[0].id)):
comment:5 follow-up: 7 Changed 14 years ago by
Keywords: | unicode added |
---|---|
Owner: | changed from Alec Thomas to Michael Renzmann |
This has been fixed in trunk with changeset [3875] more than 2 years ago (see #2493).
Anyway, this doesn't went in the other branches and I feel like to_unicode from Trac would be better coding style anyway, as you see much better what happens from it's name.
So I'll change this in trunk and will ask Michael (otaku42), the current maintainer, to backport it to the other branch(es).
comment:7 follow-ups: 8 9 Changed 14 years ago by
Status: | new → assigned |
---|
Replying to hasienda:
So I'll change this in trunk and will ask Michael (otaku42), the current maintainer, to backport it to the other branch(es).
Yes, please do so. Not sure if I backport that to earlier versions, though. I think it would be good to get a new version out that contains either just recent bug fixes, or maybe also new features such as i18n.
comment:8 Changed 14 years ago by
Replying to otaku42:
Yes, please do so. Not sure if I backport that to earlier versions, though. I think it would be good to get a new version out that contains either just recent bug fixes, or maybe also new features such as i18n.
I also think so.
comment:9 follow-up: 11 Changed 14 years ago by
Replying to otaku42:
Replying to hasienda:
So I'll change this in trunk and will ask Michael (otaku42), the current maintainer, to backport it to the other branch(es).
Yes, please do so. Not sure if I backport that to earlier versions, though. I think it would be good to get a new version out that contains either just recent bug fixes, or maybe also new features such as i18n.
Ok, at least i18n has been added to trunk today, finally, and I'll rework code related to this issue now.
How about doing a 0.6.1 with recent bug fixes and a reserve i18n for the next major release? At least this has been prepared by pushing trunk version to 0.7dev in changeset [9316].
comment:10 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [9322]) TagsPlugin: Rework string encoding for (non-ASCII) tag names, closes #5575.
This has been fixed in other branches in a different way before, however applying a method from Trac could be preferred.
comment:11 Changed 14 years ago by
Replying to hasienda:
How about doing a 0.6.1 with recent bug fixes and a reserve i18n for the next major release?
No objections from my side on this one.
Here is a simple patch.