[Tutor] empty delimiters, and None

eryksun eryksun at gmail.com
Fri Nov 29 23:30:09 CET 2013


On Fri, Nov 29, 2013 at 8:19 AM,  <ugajin at talktalk.net> wrote:
>
> On trying to run the script (before the fix) I had the following traceback
> message:
> File "measure.py", line 35, in <module>
> locale.setlocale(locale.LC_ALL, '')
> File
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py",
> line 494, in setlocale
> return _setlocale(category, locale)
> locale.Error: unsupported locale setting
>
> If I booted from the Unix file I received the following feedback:
> Setting Language: .UTF-8
> (process:82224): Gtk-WARNING **: Locale not supported by C library.
Using
> the fallback 'C' locale.

It looks like you have a misconfigured environment. ".UTF-8" is
missing the language, such as "en_GB.UTF-8".

locale.setlocale calls the C runtime setlocale. Passing an empty
string as the 2nd argument instructs setlocale to use the environment
variables LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY,
LC_NUMERIC, LC_TIME, and LANG. It uses the first one it finds. The
search order might vary depending on the implementation. Just check
them all: os.environ["LANG"], etc.

If you pass None (translated to NULL in the C call) as the 2nd
argument, then it only queries the current locale. This avoids the
immediate problem without really fixing it. The process will use the
default "C" locale.


More information about the Tutor mailing list