From: Jeroen Ruigrok van der Werven Date: Wed, 6 May 2009 05:25:42 +0000 (+0000) Subject: Wrap getpreferredencoding()'s use of setlocale in a try/except to prevent X-Git-Tag: v2.7a1~1267 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=041f465cbd0d180426cbd5ab544266b7c06fd120;p=thirdparty%2FPython%2Fcpython.git Wrap getpreferredencoding()'s use of setlocale in a try/except to prevent us from raising an exception when the locale is invalid. Issue #1443504 --- diff --git a/Lib/locale.py b/Lib/locale.py index 777bb03f4fba..f44effe6d270 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -553,7 +553,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