diff options
author | Jeroen Ruigrok van der Werven <asmodai@in-nomine.org> | 2009-05-06 05:33:24 (GMT) |
---|---|---|
committer | Jeroen Ruigrok van der Werven <asmodai@in-nomine.org> | 2009-05-06 05:33:24 (GMT) |
commit | bcf8506dcd149eaff626512adc377f49aae93de3 (patch) | |
tree | e09d9d49addfb64500fcad3310ec554a8c3ea756 /Lib | |
parent | 0a0728522d93525261b526aa0c9fe1dc80785790 (diff) | |
download | cpython-bcf8506dcd149eaff626512adc377f49aae93de3.zip cpython-bcf8506dcd149eaff626512adc377f49aae93de3.tar.gz cpython-bcf8506dcd149eaff626512adc377f49aae93de3.tar.bz2 |
Merged revisions 72375 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72375 | jeroen.ruigrok | 2009-05-06 07:25:42 +0200 (wo, 06 mei 2009) | 5 lines
Wrap getpreferredencoding()'s use of setlocale in a try/except to prevent
us from raising an exception when the locale is invalid.
Issue #1443504
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/locale.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py index 372c955..75a6435 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -564,7 +564,10 @@ else: according to the system configuration.""" if do_setlocale: oldloc = setlocale(LC_CTYPE) - setlocale(LC_CTYPE, "") + try: + setlocale(LC_CTYPE, "") + except: + pass result = nl_langinfo(CODESET) setlocale(LC_CTYPE, oldloc) return result |