From 20573e0dd0ef358ad3672a2b64f4718fd71ec980 Mon Sep 17 00:00:00 2001 From: Jeroen Ruigrok van der Werven Date: Wed, 6 May 2009 07:41:26 +0000 Subject: [PATCH] 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 ........ --- Lib/locale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/locale.py b/Lib/locale.py index 163b0440e6..1536bb594b 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -546,7 +546,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 -- 2.50.1