]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30409: locale.getpreferredencoding doesn't return result (#1672)
authorSean McCully <sean_mccully@yahoo.com>
Sun, 21 May 2017 01:44:02 +0000 (21:44 -0400)
committerVictor Stinner <victor.stinner@gmail.com>
Sun, 21 May 2017 01:44:02 +0000 (18:44 -0700)
Lib/locale.py
Misc/ACKS

index be34c5ddcd5893338550a3563443965fa0f8e98f..62aad5ae7bf96570590907c6c8ab02c023d5c47f 100644 (file)
@@ -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
index 10b5d7c84eb0d2420b3e255162ae88f712e105db..b7b58a7b1c95b8730d67756a8c0befb7ec74701e 100644 (file)
--- 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