mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-34589: Add -X coerce_c_locale command line option (GH-9378)
Add a new -X coerce_c_locale command line option to control C locale coercion (PEP 538).
This commit is contained in:
parent
7a0791b699
commit
dbdee0073c
8 changed files with 160 additions and 52 deletions
|
@ -159,13 +159,16 @@ class CmdLineTest(unittest.TestCase):
|
|||
env = os.environ.copy()
|
||||
# Use C locale to get ascii for the locale encoding
|
||||
env['LC_ALL'] = 'C'
|
||||
env['PYTHONCOERCECLOCALE'] = '0'
|
||||
code = (
|
||||
b'import locale; '
|
||||
b'print(ascii("' + undecodable + b'"), '
|
||||
b'locale.getpreferredencoding())')
|
||||
p = subprocess.Popen(
|
||||
[sys.executable, "-c", code],
|
||||
[sys.executable,
|
||||
# Disable C locale coercion and UTF-8 Mode to not use UTF-8
|
||||
"-X", "coerce_c_locale=0",
|
||||
"-X", "utf8=0",
|
||||
"-c", code],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
env=env)
|
||||
stdout, stderr = p.communicate()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue