diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 87ae2b66199..5143ed79f00 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -176,7 +176,15 @@ class CmdLineTest(unittest.TestCase): path1 = "ABCDE" * 100 path2 = "FGHIJ" * 100 env['PYTHONPATH'] = path1 + os.pathsep + path2 - p = _spawn_python('-S', '-c', 'import sys; print(sys.path)') + + code = """ +import sys +path = ":".join(sys.path) +path = path.encode("ascii", "backslashreplace") +sys.stdout.buffer.write(path)""" + code = code.strip().splitlines() + code = '; '.join(code) + p = _spawn_python('-S', '-c', code) stdout, _ = p.communicate() self.assertTrue(path1.encode('ascii') in stdout) self.assertTrue(path2.encode('ascii') in stdout)