summaryrefslogtreecommitdiffstats
path: root/Lib/locale.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-03-08 11:24:24 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-03-08 11:24:24 (GMT)
commit071ef771dc61b3b354a16d15ad8c6bbab130f96f (patch)
treecf8c7c59c1608d85e34f6cd98cd76482ea7f114f /Lib/locale.py
parentce7a112898e53f7cda6845122277271c62029ef6 (diff)
downloadcpython-071ef771dc61b3b354a16d15ad8c6bbab130f96f.zip
cpython-071ef771dc61b3b354a16d15ad8c6bbab130f96f.tar.gz
cpython-071ef771dc61b3b354a16d15ad8c6bbab130f96f.tar.bz2
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.
Diffstat (limited to 'Lib/locale.py')
-rw-r--r--Lib/locale.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index ce0ca81..448b018 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -505,7 +505,11 @@ else:
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,