setlocale() in a module/extension library

Damien Elmes resolve at repose.REMOVE.cx
Tue Aug 23 15:22:34 EDT 2005


Hi folks,

I've got a module + C extension which provides on screen display
support in X, via libxosd (http://repose.cx/pyosd). I've recently had
a report of trouble where a Russian user was unable to display any
Russian text.

I've managed to resolve the issue by inserting the following two
lines at the start of the application:

  import locale
  locale.setlocale(locale.LC_ALL, "")

.. which I presume alters the way the Russian text is passed to X by
the underlying library.

My question is this: it would be nice if every user of my library
didn't need to add the above two lines to their code. But on the other
hand, I'm unsure of the implications of modifying the locale from
within a module, and it doesn't seem very clean. Would calling
setlocale() from a library be a bad thing? If so, any alternative
recommendations would be greatly welcome.

Kind regards,

Damien



More information about the Python-list mailing list