Edgewall Software
Modify

Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#5684 closed defect (duplicate)

Error in python script, codec can't decode byte

Reported by: alexandrefelipemuller@… Owned by: Matthew Good
Priority: high Milestone:
Component: report system Version: 0.11b1
Severity: minor Keywords: unicode decode error
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

Hi guys,

I was translating my trac project to portuguese, and when I changed line 415 of /usr/share/python-support/trac/trac/ticket/report.py

in description = 'String'

This string doesn't support chars like ç ã á í used in portuguese :( But the othes string in others file accepted it

My codification is UTF-8

Python Traceback

Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, 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 "/var/lib/python-support/python2.4/trac/ticket/report.py", line 88, in process_request
    resp = self._render_view(req, db, id)
  File "/var/lib/python-support/python2.4/trac/ticket/report.py", line 241, in _render_view
    req.hdf['report.description'] = wiki_to_html(description, self.env, req)
  File "/var/lib/python-support/python2.4/trac/wiki/formatter.py", line 1000, in wiki_to_html
    return Markup(out.getvalue())
  File "/var/lib/python-support/python2.4/trac/util/html.py", line 46, in __new__
    return unicode.__new__(self, text)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)

Attachments (0)

Change History (6)

comment:1 by anonymous, 17 years ago

Resolution: wontfix
Status: newclosed

0.10.3 does not support unicode throughout. if it happens in 0.11 too pls reopen.

in reply to:  1 comment:2 by Christian Boos, 17 years ago

Description: modified (diff)
Keywords: unicode i18n added; codification removed

Replying to anonymous:

0.10.3 does not support unicode throughout. if it happens in 0.11 too pls reopen.

Not true, Trac supports unicode since 0.10.

Two remarks:

  • description = 'String' should rather be description = u'String' when String contains non-ascii characters
  • you're better off following current sandbox/i18n efforts and #5470/#5476

comment:3 by wagneryukio@…, 16 years ago

Keywords: decode error added; i18n removed
Priority: lowhigh
Resolution: wontfix
Status: closedreopened
Version: 0.10.30.11b1

Hello,

I just installed trac, (the LATEST version) and had the same problem. Here, it's what I got: Traceback (most recent call last):

File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/api.py", line 339, in send_error

'text/html')

File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/chrome.py", line 683, in render_template

return stream.render(method, doctype=doctype)

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/core.py", line 154, in render

return encode(generator, method=method, encoding=encoding)

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/output.py", line 45, in encode

output = u.join(list(iterator))

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/output.py", line 274, in call

for kind, data, pos in stream:

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/output.py", line 519, in call

for kind, data, pos in stream:

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/output.py", line 688, in call

text = mjoin(textbuf, escape_quotes=False)

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/core.py", line 379, in join

for item in seq]))

File "/usr/local/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/core.py", line 405, in escape

text = unicode(text).replace('&', '&') \

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

I was just trying to update some data about my project, and couldn't save it.

I put the priority as high because it prevents me from using it.

Thank you in advance.

Wagner

comment:4 by alexey.lustin <lustin@…>, 16 years ago

when i translate the my Trac 0.11 in to russian lang i would use directly decode
for example

   StringInMyLang = 'example russian string'.decode('utf-8')

PS besides i have allready try to write in this comment example in russian text and catch Trac exeption

comment:5 by carlos@…, 16 years ago

Is there any known workaround the issue?

If I set the default encoding to UTF-8 (or whatever) and the text being read is UTF-8, will the problem persist? How do I set the default encoding?

TIA, Carlos

comment:6 by Christian Boos, 16 years ago

Resolution: duplicate
Status: reopenedclosed

See #6932, #3908

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Matthew Good.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Matthew Good to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.