mirror of
https://github.com/python/cpython.git
synced 2025-09-19 07:00:59 +00:00
Work around Mac OS X platform encoding issues.
This commit is contained in:
parent
f18efa5643
commit
e555fc76a7
1 changed files with 6 additions and 0 deletions
|
@ -65,6 +65,9 @@ else:
|
||||||
# resulting codeset may be unknown to Python. We ignore all
|
# resulting codeset may be unknown to Python. We ignore all
|
||||||
# these problems, falling back to ASCII
|
# these problems, falling back to ASCII
|
||||||
encoding = locale.nl_langinfo(locale.CODESET)
|
encoding = locale.nl_langinfo(locale.CODESET)
|
||||||
|
if encoding is None:
|
||||||
|
# situation occurs on Mac OS X
|
||||||
|
encoding = 'ascii'
|
||||||
codecs.lookup(encoding)
|
codecs.lookup(encoding)
|
||||||
except (NameError, AttributeError, LookupError):
|
except (NameError, AttributeError, LookupError):
|
||||||
# Try getdefaultlocale well: it parses environment variables,
|
# Try getdefaultlocale well: it parses environment variables,
|
||||||
|
@ -72,6 +75,9 @@ else:
|
||||||
# bugs that can cause ValueError.
|
# bugs that can cause ValueError.
|
||||||
try:
|
try:
|
||||||
encoding = locale.getdefaultlocale()[1]
|
encoding = locale.getdefaultlocale()[1]
|
||||||
|
if encoding is None:
|
||||||
|
# situation occurs on Mac OS X
|
||||||
|
encoding = 'ascii'
|
||||||
codecs.lookup(encoding)
|
codecs.lookup(encoding)
|
||||||
except (ValueError, LookupError):
|
except (ValueError, LookupError):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue