diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2009-09-06 14:01:46 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2009-09-06 14:01:46 (GMT) |
commit | dc9bc3be978256b0cf1b38dc7714816461bde259 (patch) | |
tree | eeff5f7b66ec082b80835ae30017724615c1200e /Lib/locale.py | |
parent | d45ff2ce5afc6a385c0aebe334e1db8050745706 (diff) | |
download | cpython-dc9bc3be978256b0cf1b38dc7714816461bde259.zip cpython-dc9bc3be978256b0cf1b38dc7714816461bde259.tar.gz cpython-dc9bc3be978256b0cf1b38dc7714816461bde259.tar.bz2 |
Merged revisions 74687 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r74687 | ronald.oussoren | 2009-09-06 15:59:02 +0200 (Sun, 06 Sep 2009) | 3 lines
Fix for issue 6393: Python crashes on OSX when $LANG is set to some (but
not all) invalid values due to an invalid result from nl_langinfo
........
Diffstat (limited to 'Lib/locale.py')
-rw-r--r-- | Lib/locale.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py index f6d174c..54d4c0e 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -567,10 +567,22 @@ else: except Error: pass result = nl_langinfo(CODESET) + if not result and sys.platform == 'darwin': + # nl_langinfo can return an empty string + # when the setting has an invalid value. + # Default to UTF-8 in that case because + # UTF-8 is the default charset on OSX and + # returning nothing will crash the + # interpreter. + result = 'UTF-8' + setlocale(LC_CTYPE, oldloc) return result else: - return nl_langinfo(CODESET) + result = nl_langinfo(CODESET) + if not result and sys.platform == 'darwin': + # See above for explanation + result = 'UTF-8' ### Database |