mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Wrap getpreferredencoding()'s use of setlocale in a try/except to prevent
us from raising an exception when the locale is invalid. Issue #1443504
This commit is contained in:
parent
eaeb4c695e
commit
041f465cbd
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue