| Summary: | Test failure with Python 2 and non-English locales | ||
|---|---|---|---|
| Product: | PyXDG | Reporter: | Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA> |
| Component: | PyXDG | Assignee: | Thomas Kluyver <thomas> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | medium | CC: | ejsheldrake |
| Version: | unspecified | ||
| Hardware: | Other | ||
| OS: | All | ||
| Whiteboard: | |||
| i915 platform: | i915 features: | ||
Thanks for the report. I think the first step will be to try to make a self-contained test case that reproduces the problem for anyone in any locale. Apparently test suite of PyXDG triggers parsing of desktop entries installed in /usr/share/applications.
The following can be used to reproduce this bug in any locale:
$ cat /tmp/test.desktop
[Desktop Entry]
Name=€
$ python2.7 -c 'import xdg.Menu; menu_entry=xdg.Menu.MenuEntry("/tmp/test.desktop"); menu_entry < menu_entry'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/xdg/Menu.py", line 487, in __lt__
other = other._key()
File "/usr/lib64/python2.7/site-packages/xdg/Menu.py", line 483, in _key
return locale.strxfrm(self.DesktopEntry.getName())
UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 0: ordinal not in range(128)
$ python3.2 -c 'import xdg.Menu; menu_entry=xdg.Menu.MenuEntry("/tmp/test.desktop"); menu_entry < menu_entry'
$
Great. I've added a test and fixed the issue: http://cgit.freedesktop.org/xdg/pyxdg/commit/?id=2780bc434aac3817097a5a09b0efd93d2c373a02 |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.
1 test fails with Python 2.6 and 2.7 and non-English locales (e.g. pl_PL.UTF-8 or fr_FR.UTF-8). All tests pass with Python 3.1, 3.2 and 3.3. I use PyXDG 0.21. $ nosetests-2.6 ............./tmp/pyxdg-0.21/xdg/Menu.py:812: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if filename in tmp["mergeFiles"]: E....... ====================================================================== ERROR: test_parse_menu (test-menu.MenuTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/pyxdg-0.21/test/test-menu.py", line 39, in test_parse_menu menu = xdg.Menu.parse(self.test_file) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 574, in parse sort(tmp["Root"]) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 937, in sort sort(submenu) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 964, in sort menu.MenuEntries.sort() File "/tmp/pyxdg-0.21/xdg/Menu.py", line 490, in __lt__ return self._key() < other File "/tmp/pyxdg-0.21/xdg/Menu.py", line 483, in _key return locale.strxfrm(self.DesktopEntry.getName()) UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position 3: ordinal not in range(128) ---------------------------------------------------------------------- Ran 21 tests in 2.443s FAILED (errors=1) $ nosetests-2.7 /usr/lib64/python2.7/site-packages/nose/util.py:14: DeprecationWarning: The compiler package is deprecated and removed in Python 3.x. from compiler.consts import CO_GENERATOR ............./tmp/pyxdg-0.21/xdg/Menu.py:812: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if filename in tmp["mergeFiles"]: E....... ====================================================================== ERROR: test_parse_menu (test-menu.MenuTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/pyxdg-0.21/test/test-menu.py", line 39, in test_parse_menu menu = xdg.Menu.parse(self.test_file) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 574, in parse sort(tmp["Root"]) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 937, in sort sort(submenu) File "/tmp/pyxdg-0.21/xdg/Menu.py", line 964, in sort menu.MenuEntries.sort() File "/tmp/pyxdg-0.21/xdg/Menu.py", line 490, in __lt__ return self._key() < other File "/tmp/pyxdg-0.21/xdg/Menu.py", line 483, in _key return locale.strxfrm(self.DesktopEntry.getName()) UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position 3: ordinal not in range(128) ---------------------------------------------------------------------- Ran 21 tests in 1.960s FAILED (errors=1)