Skip to content

Commit 3b455ad

Browse files
committed
gh-150244: Fix test_create_subprocess_env_shell to handle cpython path
containing spaces On non-win32 systems, the path to the executable was not quoted, causing issues when building the command if it contains spaces, causing the test to fail.
1 parent 1d28f9a commit 3b455ad

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,7 @@ async def check_stdout_output(self, coro, output):
770770

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

0 commit comments

Comments
 (0)