]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-150244: Fix `test_create_subprocess_env_shell` to handle PATH with spaces (#150281)
authorEduardo Villalpando Mello <eduardo.villalpando.mello@gmail.com>
Sun, 24 May 2026 06:45:56 +0000 (23:45 -0700)
committerGitHub <noreply@github.com>
Sun, 24 May 2026 06:45:56 +0000 (12:15 +0530)
Lib/test/test_asyncio/test_subprocess.py

index c08eb7cf2615680903744d3253b3521cec560c5e..4ac6b23b7120fcc8ea17770479573b3befc4ef4d 100644 (file)
@@ -1,4 +1,5 @@
 import os
+import shlex
 import signal
 import sys
 import textwrap
@@ -770,9 +771,7 @@ class SubprocessMixin:
 
     def test_create_subprocess_env_shell(self) -> None:
         async def main() -> None:
-            executable = sys.executable
-            if sys.platform == "win32":
-                executable = f'"{executable}"'
+            executable = f'"{sys.executable}"' if sys.platform == "win32" else shlex.quote(sys.executable)
             cmd = f'''{executable} -c "import os, sys; sys.stdout.write(os.getenv('FOO'))"'''
             env = os.environ.copy()
             env["FOO"] = "bar"