Opened 11 years ago

Closed 10 years ago

# ascii codec can't encode character

Reported by: Owned by: anonymous Colin Guthrie normal WorkLogPlugin normal 0.11

### Description

When trying to click "stop work" with comment supplied, the following is thrown:

Traceback (most recent call last):
File "/var/lib/python-support/python2.4/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/var/lib/python-support/python2.4/trac/web/main.py", line 237, in dispatch
resp = chosen_handler.process_request(req)
File "build/bdist.linux-i686/egg/worklog/webui.py", line 160, in process_request
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position 20: ordinal not in range(128)


The error occurs, when I use characters specific to iso-8859-2 (above codes 127).

I'm new to Trac and Python, so can't help too much, sorry. Maybe this solution will help?

### comment:1 Changed 11 years ago by Colin Guthrie

I think you've hit the nail on the head with your analysis of the problem. I'll try to take a look sometime soon.

### Changed 10 years ago by Antti Kaihola

fix for r2741, trac 0.11 version

### comment:2 Changed 10 years ago by Antti Kaihola

Trac Release: 0.10 → 0.11

The patch above fixes this issue for me with a current SVN checkout of WorkLogPlugin and Trac 0.11b1.

It seems that the comment in the HTTP request is encoded in UTF-8, so trying to str() that would definitely fail. Leaving it encoded seems to give correct results, so apparently the processing chain assumes UTF-8 encoded strings all the way.

I'm not familiar with Trac internals, so this might break things on other setups.

### comment:3 Changed 10 years ago by Antti Kaihola

I just verified that the patch above works correctly also against [3075].

I haven't found any negative side effects for this patch. I'm using it on ~10 trac sites (admittedly all with a very similar configuration) for four weeks now.

I'd appreciate having this committed, since currently the plugin has to be patched on every svn update to make accented letters and unicode symbols work in stop comments.

### comment:4 Changed 10 years ago by Colin Guthrie

Resolution: → fixed new → closed

(In [3147]) Closes #1969 by applying patch by akaihola. Thanks for this and sorry I didn't commit it earlier :)

### Modify Ticket

Change Properties