[Python-3000-checkins] r61309 - in python/branches/py3k: Lib/locale.py Misc/NEWS

martin.v.loewis python-3000-checkins at python.org
Sat Mar 8 12:24:25 CET 2008


Author: martin.v.loewis
Date: Sat Mar  8 12:24:24 2008
New Revision: 61309

Modified:
   python/branches/py3k/Lib/locale.py
   python/branches/py3k/Misc/NEWS
Log:
Default to ASCII as the locale.getpreferredencoding, if the POSIX
system doesn't support CODESET and LANG isn't set or doesn't
allow deduction of an encoding.


Modified: python/branches/py3k/Lib/locale.py
==============================================================================
--- python/branches/py3k/Lib/locale.py	(original)
+++ python/branches/py3k/Lib/locale.py	Sat Mar  8 12:24:24 2008
@@ -505,7 +505,11 @@
         def getpreferredencoding(do_setlocale = True):
             """Return the charset that the user is likely using,
             by looking at environment variables."""
-            return getdefaultlocale()[1]
+            res = getdefaultlocale()[1]
+            if res is None:
+                # LANG not set, default conservatively to ASCII
+                res = 'ascii'
+            return res
     else:
         def getpreferredencoding(do_setlocale = True):
             """Return the charset that the user is likely using,

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Mar  8 12:24:24 2008
@@ -14,6 +14,13 @@
 
 - Use wchar_t functions in _locale module.
 
+Library
+-------
+
+- Default to ASCII as the locale.getpreferredencoding, if the POSIX
+  system doesn't support CODESET and LANG isn't set or doesn't
+  allow deduction of an encoding.
+
 
 What's New in Python 3.0a3?
 ===========================


More information about the Python-3000-checkins mailing list