]> granicus.if.org Git - python/commitdiff
test_subprocess: use surrogateescape error handler to write shell scripts
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 23:46:43 +0000 (23:46 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 23:46:43 +0000 (23:46 +0000)
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.

Lib/test/test_subprocess.py

index c21de196d101449430ccbae1bbf6440b3744518b..a08a8aa4b0a4ce127b929f7e89961ff8fb3134de 100644 (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)