Skip to content

subprocess.Popen doesn't properly escape < or > for windows batch files #133545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jefsayshi opened this issue May 7, 2025 · 0 comments · May be fixed by #134544
Open

subprocess.Popen doesn't properly escape < or > for windows batch files #133545

jefsayshi opened this issue May 7, 2025 · 0 comments · May be fixed by #134544
Labels
OS-windows stdlib Python modules in the Lib dir topic-subprocess Subprocess issues. type-bug An unexpected behavior, bug, or error

Comments

@jefsayshi
Copy link

jefsayshi commented May 7, 2025

Bug report

Bug description:

subprocess.Popen doesn't properly escape < or > for windows batch files

example.bat

echo %*

example.py

import subprocess
from pathlib import Path

batch_file = Path().cwd() / 'example.bat'
subprocess.Popen([batch_file, 'arg1', 'arg2<99'])

Error

The system cannot find the file specified

Adding a space causes it to be correctly escaped:

subprocess.Popen([batch_file, 'arg1', 'arg2 <99'])

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

@jefsayshi jefsayshi added the type-bug An unexpected behavior, bug, or error label May 7, 2025
@picnixz picnixz added OS-windows topic-subprocess Subprocess issues. stdlib Python modules in the Lib dir labels May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows stdlib Python modules in the Lib dir topic-subprocess Subprocess issues. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants