Edgewall Software
Modify

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#5684 closed defect (duplicate)

Error in python script, codec can't decode byte

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

Description (last modified by cboos)

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 follow-up: Changed 7 years ago by anonymous

  • Resolution set to wontfix
  • Status changed from new to closed

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

comment:2 in reply to: ↑ 1 Changed 7 years ago by cboos

  • 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 Changed 7 years ago by wagneryukio@…

  • Keywords decode error added; i18n removed
  • Priority changed from low to high
  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Version changed from 0.10.3 to 0.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 Changed 7 years ago by alexey.lustin <lustin@…>

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 Changed 7 years ago by carlos@…

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 Changed 7 years ago by cboos

  • Resolution set to duplicate
  • Status changed from reopened to closed

See #6932, #3908

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain mgood.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from mgood 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.