[Python-Dev] logging module broken because of locale

Mihai Ibanescu misa at redhat.com
Tue Jul 18 14:40:19 CEST 2006


On Mon, Jul 17, 2006 at 03:39:55PM -0400, Mihai Ibanescu wrote:
> Hi,
> 
> This is reported on sourceforge:
> 
> http://sourceforge.net/tracker/index.php?func=detail&aid=1524081&group_id=5470&atid=105470
> 
> I am willing to try and patch the problem, but I'd like to discuss my ideas
> first.
> 
> The basic problem is that, in some locale, "INFO".lower() != "info". So,
> initializing a dictionary with keys that appear to be lower-case in English
> is unsafe for other locale.
> 
> Now, the other problem is, people can choose to initialize the locale any time
> they want, and can choose to change it too. My initial approach was to create
> the dictionary with strings to which lower() was explicitly called.
> 
> But, since priority_names is class-scoped, it gets evaluated at module import
> time, which is way too early in the game (most likely the locale will be set
> afterwards).
> 
> Any thoughts on the proper way to approach this?

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)?

Thanks,
Misa


More information about the Python-Dev mailing list