Edgewall Software

Opened 15 years ago

Last modified 13 years ago

#8538 closed defect

UnicodeDecodeError on mercurial-plugin 0.11 — at Version 1

Reported by: anonymous Owned by: Christian Boos
Priority: highest Milestone: plugin - mercurial
Component: plugin/mercurial Version: 0.11.4
Severity: major Keywords: unicode
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

This buf was reported in #8018, #7799, and #7160 but solution on #7160:

os.environHGENCODING = "UTF-8" not solves error.

We solve the error with this patch:

When you want to open dir in browse source with a file or child file with an accented charcater (ó) the error shows:

Most recent call last: 
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 205, in dispatch
  resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/versioncontrol/web_ui/browser.py", line 360, in process_request
  'dir': node.isdir and self._render_dir(req, repos, node, rev),
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/versioncontrol/web_ui/browser.py", line 406, in _render_dir
  entries = [entry(n) for n in node.get_entries()]
File "/var/trac/scrum.pxgo.es/norprevencion_openerp/plugins/TracMercurial-0.11.0.7-py2.5.egg/tracext/hg/backend.py", line 697, in get_entriesFile "/var/trac/scrum.pxgo.es/norprevencion_openerp/plugins/TracMercurial-0.11.0.7-py2.5.egg/tracext/hg/backend.py", line 605, in findnode

Patch:

In TracMercurial-0.11.0.7-py2.5.egg/tracext/hg/backend.py method findnode:

for f in self.repos.repo.changectx(rev).files():
    f = unicode(f, 'utf-8', 'replace')  

#convert to unicode with replace and utf-8 encode and the name of file process correctly.

Then the dir works if the file is another dir else the error shows in other part of code:

Most recent call last: 
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 205, in dispatch
  resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/versioncontrol/web_ui/browser.py", line 360, in process_request
  'dir': node.isdir and self._render_dir(req, repos, node, rev),
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/versioncontrol/web_ui/browser.py", line 406, in _render_dir
  entries = [entry(n) for n in node.get_entries()]
File "/var/trac/scrum.pxgo.es/norprevencion_openerp/plugins/TracMercurial-0.11.0.7-py2.5.egg/tracext/hg/backend.py", line 691, in get_entriesFile "/usr/local/lib/python2.5/posixpath.py", line 65, in join
  path += '/' + b

Patch:

In TracMercurial-0.11.0.7-py2.5.egg/tracext/hg/backend.py method get_entries the same:

for entry in self.entries:
    entry = unicode(entry, 'utf-8', 'replace')

#convert the file's name to unicode with replace and encode in utf-8

Then the dir with file works but when you want to open the file and error shows:

Most recent call last: 
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request
  dispatcher.dispatch(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/main.py", line 205, in dispatch
  resp = chosen_handler.process_request(req)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/versioncontrol/web_ui/browser.py", line 373, in process_request
  href=req.href.changeset(node.rev, node.created_path)))
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/href.py", line 163, in <lambda>
  self._derived[name] = lambda *args, **kw: self(name, *args, **kw)
File "/usr/local/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/href.py", line 148, in __call__
  if arg != None])

This bug raise on Trac, i don't know if in new versions it solves, occurs beacause teh name of file have a accented character and in url not escapes the accented character.

Change History (1)

comment:1 by Christian Boos, 15 years ago

Description: modified (diff)
Keywords: unicode added
Milestone: 0.11.6not applicable

Any chance for me to get a clone of this repository (or better, a small sample one that will produce similar errors)?

Note: See TracTickets for help on using tickets.