From: Sean McCully Date: Sun, 21 May 2017 01:44:02 +0000 (-0400) Subject: bpo-30409: locale.getpreferredencoding doesn't return result (#1672) X-Git-Tag: v2.7.14rc1~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cef8b1741c03a09ea7371947dc65f632c61ef8ad;p=thirdparty%2FPython%2Fcpython.git bpo-30409: locale.getpreferredencoding doesn't return result (#1672) --- diff --git a/Lib/locale.py b/Lib/locale.py index be34c5ddcd58..62aad5ae7bf9 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -617,22 +617,19 @@ 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: result = nl_langinfo(CODESET) - if not result and sys.platform == 'darwin': - # See above for explanation - result = 'UTF-8' + + 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' + return result ### Database diff --git a/Misc/ACKS b/Misc/ACKS index 10b5d7c84eb0..b7b58a7b1c95 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -904,6 +904,7 @@ Arnaud Mazin Pam McA'Nulty Matt McClure Rebecca McCreary +Sean McCully Kirk McDonald Chris McDonough Greg McFarlane