Bug: (Locale) IDLE/Tkinter/Python?

Guido van Rossum guido at CNRI.Reston.VA.US
Thu Oct 7 08:11:02 EDT 1999


[me]
> > Hm, that's odd.  Python is supposed to ignore the locale when you use
> > atof(); the locale module exports a version of atof() that honors the
> > locale after you call locale.setlocale(locale.LC_ALL, "").
[Adrian Eyre]
> Even if setlocale() was not called through the Python wrapper?

Perhaps not.  Python needs the locale to be "C" for its own internal
purposes.

> > What platform are you on?
> Win32
> 
> > It seems that perhaps the Tcl version you
> > are using calls setlocale() on that platform?
> In the embedding code, there is a call to setlocale(LC_ALL, "") before
> Py_Initialise().

What embedding code?  I thought you were using IDLE.  Are you saying
that you are using IDLE from an embedding application?  (It is always
necessary if any 3rd party C code is involved when reporting a Python
problem; embedding counts as such :-)

If so, why do you call setlocale(LC_ALL, "")?

There may be no good solution if your embedding application needs to
do that -- there are too many places in the Python runtime that expect
the locale to be C.  I suppose this could be fixed by not using any of
those, but (a) it's painful to write your own atof(), %e, %f, %g
formatter in a platform independent manner with the best accuracy, (b)
it seems such a waste of effort since the C library has one, (c)
finding and fixing all locale dependencies (there are others!) in the
Python source code is about as much fun as systematically searching
for Y2K bugs in a program of similar size.

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list