Commit 08167ddf authored by Victor Stinner's avatar Victor Stinner

test_subprocess: use surrogateescape error handler to write shell scripts

test_args_string() and test_call_string() create shell scripts including the
path to the Python executable: use surrogateescape to encode paths including
surrogate characters.
parent 032fc6d8
...@@ -752,7 +752,7 @@ class POSIXProcessTestCase(BaseTestCase): ...@@ -752,7 +752,7 @@ class POSIXProcessTestCase(BaseTestCase):
# args is a string # args is a string
fd, fname = mkstemp() fd, fname = mkstemp()
# reopen in text mode # reopen in text mode
with open(fd, "w") as fobj: with open(fd, "w", errors="surrogateescape") as fobj:
fobj.write("#!/bin/sh\n") fobj.write("#!/bin/sh\n")
fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable) sys.executable)
...@@ -795,7 +795,7 @@ class POSIXProcessTestCase(BaseTestCase): ...@@ -795,7 +795,7 @@ class POSIXProcessTestCase(BaseTestCase):
# call() function with string argument on UNIX # call() function with string argument on UNIX
fd, fname = mkstemp() fd, fname = mkstemp()
# reopen in text mode # reopen in text mode
with open(fd, "w") as fobj: with open(fd, "w", errors="surrogateescape") as fobj:
fobj.write("#!/bin/sh\n") fobj.write("#!/bin/sh\n")
fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" % fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable) sys.executable)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment