[Python-modules-team] Bug#611923: Bug#611923: python-xdg: wrong behaviour breaking apps on non-supported locale

Yann Dirson ydirson at free.fr
Fri Feb 4 18:39:50 UTC 2011


On Fri, Feb 04, 2011 at 09:37:32AM +0100, Piotr O??arowski wrote:
> [Yann Dirson, 2011-02-03]
> > In [6]: print "%s" % e.getName()
> > ------> print("%s" % e.getName())
> > Échecs
> 
> please do not use ipython to test encoding related issues, it has
> problems...

OK - but that was only for ease of reproduction, the problem happens
with real apps.

> > UnicodeEncodeError: 'ascii' codec can't encode character u'\xc9' in position 0: ordinal not in range(128)
> 
> .encode('utf-8')?

Sure, after .encode('utf-8') the problem does not show up, but it
would be meaningless, as the reason for the failure is most probably
that the locale-derived encoding is that of "C".

The problem as I see it is rather that pyxdg uses the language code
from the environment, when libc has no knowledge about it - and that
it should instead not use a localized string at all, just like other
programs do (eg. I like to use date(1) as a reference for
locale-related behaviour).

Hope that clarifies the problem.

-- 
Yann





More information about the Python-modules-team mailing list