Edgewall Software

Ticket #5684 (closed defect: duplicate)

Opened 2 years ago

Last modified 11 months ago

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:

Description (last modified by cboos) (diff)

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

Change History

follow-up: ↓ 2   Changed 2 years ago by anonymous

  • status changed from new to closed
  • resolution set to wontfix

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

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

  • keywords unicode i18n added; codification removed
  • description modified (diff)

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

  Changed 16 months ago by wagneryukio@…

  • keywords decode error added; i18n removed
  • priority changed from low to high
  • status changed from closed to reopened
  • resolution wontfix deleted
  • 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

  Changed 16 months 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

  Changed 15 months 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

  Changed 15 months ago by cboos

  • status changed from reopened to closed
  • resolution set to duplicate

See #6932, #3908

Add/Change #5684 (Error in python script, codec can't decode byte)

Author


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


Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from mgood. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.