Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#12886 closed defect (fixed)

UnicodeError: source returned bytes, but no encoding specified

Reported by: Fabian.Scheler@… Owned by: Kirk
Priority: normal Component: BudgetingPlugin
Severity: critical Keywords:
Cc: Trac Release: 1.0

Description (last modified by Jun Omae)

The stack trace looks like this:

File "/usr/local/lib/python2.7/dist-packages/trac/web/", line 562, in _dispatch_request
File "/usr/local/lib/python2.7/dist-packages/trac/web/", line 269, in dispatch
File "/usr/local/lib/python2.7/dist-packages/trac/web/", line 1079, in render_template
  stream |= self._filter_stream(req, method, filename, stream, data)
File "/usr/local/lib/python2.7/dist-packages/genshi/", line 133, in __or__
  return Stream(_ensure(function(self)), serializer=self.serializer)
File "/usr/local/lib/python2.7/dist-packages/trac/web/", line 1331, in inner
File "build/bdist.linux-x86_64/egg/ticketbudgeting/", line 327, in filter_stream
  stream |= Transformer('.//fieldset [@id="properties"]').after(HTML(fieldset))
File "/usr/local/lib/python2.7/dist-packages/genshi/", line 442, in HTML
  return Stream(list(HTMLParser(BytesIO(text), encoding=encoding)))
File "/usr/local/lib/python2.7/dist-packages/genshi/", line 273, in _ensure
  event =
File "/usr/local/lib/python2.7/dist-packages/genshi/", line 449, in _coalesce
  for kind, data, pos in chain(stream, [(None, None, None)]):
File "/usr/local/lib/python2.7/dist-packages/genshi/", line 337, in _generate
  raise UnicodeError("source returned bytes, but no encoding specified")

This error should be caused by a missing adaptation for Genshi 0.7, the attached patch should solve the problem.

Attachments (1) (724 bytes) - added by anonymous 6 years ago.

Download all attachments as: .zip

Change History (8)

Changed 6 years ago by anonymous

Attachment: added

comment:1 Changed 6 years ago by Jun Omae

Description: modified (diff)

comment:2 Changed 6 years ago by mwg@…

was bitten by this bug as well, and the attached patch helped. would like to see it integrated into Budgeting Plugin trunk

comment:3 Changed 6 years ago by Jun Omae

I don't think the patch fixes it. The patch would just change fieldset variable to u'fieldset' literal. It breaks the plugin features.

-                stream |= Transformer('.//fieldset [@id="properties"]').after(HTML(fieldset))
+                stream |= Transformer('.//fieldset [@id="properties"]').after(HTML(u"""fieldset"""))

I'll post a patch later.

comment:4 Changed 6 years ago by Fabian.Scheler@…

Well, I am neither an experienced python coder nor have I used Genshi so far. I simply tried to silence the error above. So, presumable you are right - nevertheless, I would really be interested in a fix; it would be great if you could post a patch. Thanks!

comment:5 Changed 6 years ago by Kirk

Index: ticketbudgeting/
--- ticketbudgeting/	(revision 16144)
+++ ticketbudgeting/	(working copy)
@@ -359,7 +351,7 @@
             if 'by' in req.args:
                 by = req.args['by']
             budget_stats, stats_by = self._get_milestone_html(req, by)
-            stats_by = "<fieldset><legend>Budget</legend><table>%s</table></fieldset>" % stats_by
+            stats_by = u"""<fieldset><legend>Budget</legend><table>%s</table></fieldset>""" % stats_by
             stream |= Transformer('//form[@id="stats"]').append(HTML(stats_by))
             stream |= Transformer('//div[@class="info"]').append(HTML(budget_stats))
         return stream

comment:6 Changed 6 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

In 16146:

0.6.6dev: Fix UnicodeError with Genshi 0.7

Patch by linefeed. Fixes #12886.

comment:7 Changed 6 years ago by Ryan J Ollos

Owner: changed from Franz to Kirk

Feel free to push a better fix, but this at least fixes the acute problem.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Kirk.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

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

Note: See TracTickets for help on using tickets.