[Python-Dev] locale and LC_NUMERIC

"Martin v. Löwis" martin at v.loewis.de
Mon Jan 9 08:57:13 CET 2006


Neal Norwitz wrote:
> I know very little about locale's.  /f assigned me a bug
> http://python.org/sf/1391872 which suggests I run all the tests in a
> different locale than C.  I think this is a good idea, but when I set
> LANG or LC_ALL or LC_CTYPE in the env't the locale isn't set without
> me calling locale.setlocale().  Shouldn't we maintain the value from
> the env't?

I feel I'm lacking some link here: why do you think we should do that?

> The problem I found is in Python/pythonrun.c.  At least I think that's
> the problem.  Around line 230-240 we call setlocale(NULL), then call
> setlocale("").  Then later on we restore the locale by calling
> setlocale() with the return result from setlocale(NULL).

Right.

> The man page on my box (gentoo) says that passing NULL returns the
> current locale() while passing "" sets the locale from the env't
> variable.  Should we just capture the results of setlocale("")?

Again: why?

> If my understanding is wrong, how can I start python with the correct
> locale?

What does "start with the correct locale" mean? What is the "correct
locale"? Python should work in any locale, and locale.format
should always give the locale-specific formatting, whereas "%f" % value
should always give the result from the "C" locale (regardless of
whether the application has called setlocale or not).

Regards,
Martin



More information about the Python-Dev mailing list