summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/locale.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index ce0ca817eb..448b018a61 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,