Thanks to visit codestin.com
Credit goes to github.com

Skip to content

subprocess.run adds quotes in unexpected places #135696

Closed as not planned
Closed as not planned
@svetli97

Description

@svetli97

Bug report

Bug description:

I was trying to compile code with gcc using this function and it mangled the parameters I needed to pass to the compiler:

subprocess.run(['g++', '-I"some path"', 'test.cpp', '-o', 'test.exe'])

Apparently this function decided to split the second argument into two and then add extra "" to the second part. Which produces an invalid path.

I pass "some path" in quotes already because it is part of the second argument, not the whole second argument. So I can't expect this function to split and then add quotes because there is no strict rule for how a program I'm calling should parse its parameters.

If this function is going to make random assumptions about whether something is a path or not and add quotes, then why isn't it checking if the path was already quoted?

I chose to use this library specifically to avoid all the shell BS but I guess it wasn't enough :(

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-subprocessSubprocess issues.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions