[Sugar-devel] gettext vs unicode problem in wireless key dialog

Daniel Drake dsd at laptop.org
Mon Oct 8 17:31:21 EDT 2012


Hi,

Sorry for not doing my homework, a bit overloaded...
What was the result of the discussion where _("str1") % str2 was
causing problems (assuming it has been resolved)?

The issue I'm looking at is that we do this exact pattern in
keydialog.py and it is raising an exception.

The Spanish translation of str1 includes accents, and gettext returns
it as a str. str2 is guaranteed to be unicode. And this is an unhappy
combination:

>>> "fóo%s" % u"bar"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
1: ordinal not in range(128)


If posting a fix is easier than replying to this mail, please do so :)
The string is: A wireless encryption key is required for the wireless
network '%s'

Thanks
Daniel


More information about the Sugar-devel mailing list