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

Skip to content

subprocess.CalledProcessError misquotes list-style commands #151485

Description

@BenjyWiener

Bug report

Bug description:

import subprocess
subprocess.check_call(['false'])

Output:

Traceback (most recent call last):
...
subprocess.CalledProcessError: Command '['false']' returned non-zero exit status 1.

Expected output:

Traceback (most recent call last):
...
subprocess.CalledProcessError: Command ['false'] returned non-zero exit status 1.

subprocess.CalledProcessError.__str__ manually quotes cmd via "... '%s' ..." instead of "%r". This results in (marginally) confusing error messages when cmd is a list or a string containing '.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-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