]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41385: Fix test_executable_without_cwd on Windows (GH-21608)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 26 Jul 2020 07:38:52 +0000 (00:38 -0700)
committerGitHub <noreply@github.com>
Sun, 26 Jul 2020 07:38:52 +0000 (00:38 -0700)
(cherry picked from commit b1a87300a06324c9fc7d6553906ed914489465aa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_subprocess.py

index aced87694cf7b6a924e5b9ad3f5607f28614de80..ba2844da9add977e964ce4675575b6c7448f0efc 100644 (file)
@@ -373,7 +373,9 @@ class ProcessTestCase(BaseTestCase):
         # matches *expected_cwd*.
         p = subprocess.Popen([python_arg, "-c",
                               "import os, sys; "
-                              "sys.stdout.write(os.getcwd()); "
+                              "buf = sys.stdout.buffer; "
+                              "buf.write(os.getcwd().encode()); "
+                              "buf.flush(); "
                               "sys.exit(47)"],
                               stdout=subprocess.PIPE,
                               **kwargs)
@@ -382,7 +384,7 @@ class ProcessTestCase(BaseTestCase):
         self.assertEqual(47, p.returncode)
         normcase = os.path.normcase
         self.assertEqual(normcase(expected_cwd),
-                         normcase(p.stdout.read().decode("utf-8")))
+                         normcase(p.stdout.read().decode()))
 
     def test_cwd(self):
         # Check that cwd changes the cwd for the child process.