diff options
Diffstat (limited to 'Lib/test/test_subprocess.py')
| -rw-r--r-- | Lib/test/test_subprocess.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 552b9f2..f2dbdc2 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -765,12 +765,16 @@ class ProcessTestCase(BaseTestCase): def test_undecodable_env(self): for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')): - value_repr = repr(value).encode("ascii") + value_repr = ascii(value).encode("ascii") # test str with surrogates - script = "import os; print(repr(os.getenv(%s)))" % repr(key) + script = "import os; print(ascii(os.getenv(%s)))" % repr(key) env = os.environ.copy() env[key] = value + # Force surrogate-escaping of \xFF in the child process; + # otherwise it can be decoded as-is if the default locale + # is latin-1. + env['PYTHONFSENCODING'] = 'ascii' stdout = subprocess.check_output( [sys.executable, "-c", script], env=env) @@ -780,7 +784,7 @@ class ProcessTestCase(BaseTestCase): # test bytes key = key.encode("ascii", "surrogateescape") value = value.encode("ascii", "surrogateescape") - script = "import os; print(repr(os.getenv(%s)))" % repr(key) + script = "import os; print(ascii(os.getenv(%s)))" % repr(key) env = os.environ.copy() env[key] = value stdout = subprocess.check_output( |
