mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
Merged revisions 72375 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72375 | jeroen.ruigrok | 2009-05-06 07:25:42 +0200 (wo, 06 mei 2009) | 5 lines 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
0a0728522d
commit
bcf8506dcd
1 changed files with 4 additions and 1 deletions
|
|
@ -564,7 +564,10 @@ def getpreferredencoding(do_setlocale = True):
|
|||
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