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.
This commit is contained in:
Victor Stinner 2010-10-16 23:46:43 +00:00
parent 61aad57dc9
commit f6782ac0b6
1 changed files with 2 additions and 2 deletions

View File

@ -752,7 +752,7 @@ class POSIXProcessTestCase(BaseTestCase):
# args is a string
fd, fname = mkstemp()
# 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("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)
@ -795,7 +795,7 @@ class POSIXProcessTestCase(BaseTestCase):
# call() function with string argument on UNIX
fd, fname = mkstemp()
# 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("exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)