[issue20999] setlocale, getlocale succession --> ValueError or (None, None)

Ned Deily report at bugs.python.org
Fri Mar 21 08:12:02 CET 2014


Ned Deily added the comment:

It's hard to be absolutely sure what is going on here since you show several different interpreters and appear to be running on a non-standard, unsupported platform but, as David noted, the primary issue is that the process locale has almost certainly not been set to a correct value.  In general, OS X does not set a default locale for a login process, although programs like Terminal.app may do so by default when they start a login shell for you.  But if you login via ssh, for example, no locale environment variable will be set unless you do it yourself.  You can examine the environment variables in the running interpreter with:

>>> import os,pprint
>>> pprint.pprint(dict(os.environ))
[...]
'LANG': 'en_US.UTF-8',
[...]

Look for LANG or LC_ALL variables.  You can also use locale.getdefaultlocale() to see what the locale module is using as a default.  You can override or establish a default by setting the LANG environment variable in your shell session; to do it "permanently", add the setting to your login shell's startup profile.  For example:

export LANG=en_US.UTF-8

The secondary issue is the segfault.  You say you are running on "Mountain Lion 10.9.1" but OS X Mountain Lion is 10.8.x.  If you are, in fact, running on 10.9.1 (also known an Mavericks) with the python.org 3.3.2, the segfault using the interactive interpreter is the problem documented in Issue18458 and has nothing to do with locale.  The solution for that is to upgrade to a more recent Python 3, either Python 3.3.5 or the newly-released 3.4.0.

----------
nosy: +ned.deily
resolution:  -> works for me
stage:  -> committed/rejected
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20999>
_______________________________________


More information about the Python-bugs-list mailing list