[Python-Dev] logging module broken because of locale

Mihai Ibanescu misa at redhat.com
Tue Jul 18 20:52:38 CEST 2006


On Tue, Jul 18, 2006 at 07:54:28PM +0200, "Martin v. Löwis" wrote:
> Mihai Ibanescu wrote:
> > To follow up on my own email: it looks like, even though in some locale
> > "INFO".lower() != "info"
> > 
> > u"INFO".lower() == "info" (at least in the Turkish locale).
> > 
> > Is that guaranteed, at least for now (for the current versions of python)?
> 
> It's guaranteed for now; unicode.lower is not locale-aware.

OK, should I write a patch for the logging module to convert the string to
unicode before applying lower()? So far that seems like the way to go.

Maybe this could also be explained in the documentation:

http://docs.python.org/lib/node323.html

I don't think I've seen it in the locale documentation that locale settings do
not affect unicode strings, and that particular page says 

<quote>
If, when coding a module for general use, you need a locale independent version
of an operation that is affected by the locale (such as string.lower(), or
certain formats used with time.strftime()), you will have to find a way to do
it without using the standard library routine.
</quote>

Unicode might be a perfectly acceptable suggestion for others too.

Misa


More information about the Python-Dev mailing list