Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#801 closed defect (fixed)

Encoding problems with strings

Reported by: jean-baptiste.note@… Owned by: hvr
Priority: normal Component: GitPlugin
Severity: normal Keywords:
Cc: jean-baptiste.note@… Trac Release: 0.10



My git commit logs have UTF-8 characters in them (essentially, unbreakable spaces, due to a lingering finger on the alt key in a UTF8 environment). This yields the following error:

Python Traceback

Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/trac/web/", line 356, in dispatch_request


File "/usr/lib/python2.4/site-packages/trac/web/", line 224, in dispatch

resp = chosen_handler.process_request(req)

File "/usr/lib/python2.4/site-packages/trac/versioncontrol/web_ui/", line 131, in process_request

self._render_directory(req, repos, node, rev)

File "/usr/lib/python2.4/site-packages/trac/versioncontrol/web_ui/", line 156, in _render_directory

changes = get_changes(self.env, repos, [irev? for i in info])

File "/usr/lib/python2.4/site-packages/trac/versioncontrol/web_ui/", line 47, in get_changes

shorten=True, absurls=absurls)

File "/usr/lib/python2.4/site-packages/trac/wiki/", line 1006, in wiki_to_oneliner

OneLinerFormatter(env, absurls, db).format(wikitext, out, shorten)

File "/usr/lib/python2.4/site-packages/trac/wiki/", line 914, in format

result = re.sub(, self.replace, result)

File "", line 142, in sub

return _compile(pattern, 0).sub(repl, string, count)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 5: ordinal not in range(128)

Changing the locale environment variable in apache with SetEnv to be UTF8 does not change anything in the plugin (it does change for python, though, as I had to generate the associated locale before trac could work again). So I resorted to the following hack. I'm a complete python newbie, so i don't know if this makes sense.


Attachments (1)

gitplugin.patch (612 bytes) - added by anonymous 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by anonymous

comment:1 Changed 8 years ago by hvr

  • Status changed from new to assigned
  • Trac Release changed from 0.9 to 0.10

thanks, that makes actually some sense :-)

...on further investigation, it turns out there's a git-repo-config(1) variable named i18n.commitEncoding which is used to define a per-repo encoding of commit messages; thus a proper fix is to decide what to do based on its setting.

comment:2 Changed 8 years ago by hvr

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [1380]) make Storage.read_commit() return unicode objects, based on the encoding set via i18n.commitEncoding

fixes #801

Add Comment

Modify Ticket

as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from hvr. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.