Skip to content

Commit 55718cb

Browse files
authored
gh-150244: Fix test_create_subprocess_env_shell to handle PATH with spaces (#150281)
1 parent fad0674 commit 55718cb

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shlex
23
import signal
34
import sys
45
import textwrap
@@ -770,9 +771,7 @@ async def check_stdout_output(self, coro, output):
770771

771772
def test_create_subprocess_env_shell(self) -> None:
772773
async def main() -> None:
773-
executable = sys.executable
774-
if sys.platform == "win32":
775-
executable = f'"{executable}"'
774+
executable = f'"{sys.executable}"' if sys.platform == "win32" else shlex.quote(sys.executable)
776775
cmd = f'''{executable} -c "import os, sys; sys.stdout.write(os.getenv('FOO'))"'''
777776
env = os.environ.copy()
778777
env["FOO"] = "bar"

0 commit comments

Comments
 (0)