On 7/22/2011 4:28 PM, Remy Blank wrote:
Christian Boos wrote:
Looks like the fileobj.read() above returns a snippet which is already a
unicode string, and in the case of this admin_plugins.html file this
snippet contains:
a.text("\u2013")
as a replacement for:
a.text("–")
I haven't looked at the exact mechanism in Babel, but at least it seems
very wrong to decode an unicode string... as this goes through an
intermediate encode step using 'ascii' (see
http://trac.edgewall.org/wiki/UnicodeEncodeError#decode for the gory
details).
Not sure about that. I have found the cause as being [genshi:1157],
where the default encoding was changed from utf-8 to `None`.
Well, that change explains why the fileobj.read() now produces unicode ;-)
But nevertheless it would be better if Babel would just be able to cope
with that.
My feeling is that we just need to pass an 'encoding': 'utf-8' somewhere
in setup.py, but I haven't found where.
How is trac.dist.extract_javascript_script? I can't find a reference to
that anywhere in the code, and that's where the encoding option is missing.
It's used via the toplevel *.cfg files, more specifically message-js.cfg
for specifying the [extractors] and setup.cfg for the options
[extract_messages_js]. But it doesn't seem you can pass 'encoding =
utf-8' there ("command 'extract_messages' has no such option
'encoding'") and the known option 'charset' is only for the output.
Anyway, that wouldn't change the fact that the fileobj would produce
unicode, so the "fix" should rather be in trac/dist.py directly:
Index: trac/dist.py
===================================================================
--- trac/dist.py (revision 10762)
+++ trac/dist.py (working copy)
@@ -221,6 +221,8 @@
stream = Stream(XMLParser(fileobj))
stream.select('//script[@type="text/javascript"]').render(out=out)
out.seek(0)
+ # Babel expects utf-8 str but Genshi r1157 produces unicode...
+ out = StringIO(out.getvalue().encode('utf-8'))
return extract_javascript(out, keywords, comment_tags, options)
-- Christian
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.