Bug: (Locale) IDLE/Tkinter/Python?

Adrian Eyre a.eyre at optichrome.com
Thu Oct 7 09:40:34 EDT 1999


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

Why not? It's useful for interactively testing inbuilt extension modules.
These are built into the code and initialised before calling any Python
scripts we run.

I would have like to embed PythonWin (the debgger is better, especially
in the latest release), but it doesn't want to work. Perhaps this is
because the embedding app isn't MFC. I'm not too sure about this one.


> (It is always necessary if any 3rd party C code is involved when
> reporting a Python problem; embedding counts as such :-)

I see. I thought, since the ability to do this was there, it would be
okay to use it. :-)


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

The rest of the code relies on it. (e.g. to set the decimal point
separator for internationalisation purposes.

> 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.

So how come it's okay to set the locale in Python. Surely this just calls
the equivalent function in C.

Perhaps if I call setlocale(LC_ALL, "C") before I initialise Python, then
call Python's setlocale() with the original locale before I run any scripts.


> 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.

This almost implies that Python's version of setlocale() does something
completely different from the C version.

--------------------------------------------
Adrian Eyre <mailto:a.eyre at optichrome.com>
Optichrome Computer Solutions Ltd
Maybury Road, Woking, Surrey, GU21 5HX, UK
Tel: +44 1483 740 233  Fax: +44 1483 760 644
http://www.optichrome.com
--------------------------------------------





More information about the Python-list mailing list