Wrap getpreferredencoding()'s use of setlocale in a try/except to prevent

us from raising an exception when the locale is invalid.

Issue #1443504
parent eaeb4c69
......@@ -553,7 +553,10 @@ else:
according to the system configuration."""
if do_setlocale:
oldloc = setlocale(LC_CTYPE)
setlocale(LC_CTYPE, "")
try:
setlocale(LC_CTYPE, "")
except:
pass
result = nl_langinfo(CODESET)
setlocale(LC_CTYPE, oldloc)
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment