-
Notifications
You must be signed in to change notification settings - Fork 24
create_subprocess_shell on Windows corrupts embedded quotes #153
Copy link
Copy link
Closed
Labels
Programmers WantedAdditional Programmers wanted for writing a fix or helping with the review process.Additional Programmers wanted for writing a fix or helping with the review process.TODOPlanned but others are welcome to implement and submit pull requests for these items as well.Planned but others are welcome to implement and submit pull requests for these items as well.bugSomething isn't workingSomething isn't working
Description
Metadata
Metadata
Assignees
Labels
Programmers WantedAdditional Programmers wanted for writing a fix or helping with the review process.Additional Programmers wanted for writing a fix or helping with the review process.TODOPlanned but others are welcome to implement and submit pull requests for these items as well.Planned but others are welcome to implement and submit pull requests for these items as well.bugSomething isn't workingSomething isn't working
On Windows,
create_subprocess_shellre-escapes quotes inside the command, soanything with double quotes reaches the child corrupted. The same command works on
the stdlib asyncio loop and on uvloop (Linux).
This commonly breaks python -c commands.I feel like this was intentionally left. I would love to know the reasoning if it was.
Reproduce Bug
Result
hi(rc 0)-cargument and fails withSyntaxError: unterminated string literal(rc 1)I ran into this while building an agentic AI app. The agent often generates shell
commands like python -c with quoted code strings, and those almost always include
quotes. With winloop (through uvicorn) those commands fail or produce no output.
The same commands work fine with the stdlib asyncio loop.
Root cause
Winloop passes the shell command to cmd.exe as separate arguments, and libuv
re-escapes the quotes. asyncio builds one command string (cmd.exe /c plus the
full command wrapped in quotes) instead, so the quotes are not mangled.
Environment