diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 38b655f2f7b9d2..6fe2ec98fb4088 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -145,13 +145,13 @@ def __init__(self, returncode, cmd, output=None, stderr=None): def __str__(self): if self.returncode and self.returncode < 0: try: - return "Command '%s' died with %r." % ( + return "Command %r died with %r." % ( self.cmd, signal.Signals(-self.returncode)) except ValueError: - return "Command '%s' died with unknown signal %d." % ( + return "Command %r died with unknown signal %d." % ( self.cmd, -self.returncode) else: - return "Command '%s' returned non-zero exit status %d." % ( + return "Command %r returned non-zero exit status %d." % ( self.cmd, self.returncode) @property diff --git a/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst b/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst new file mode 100644 index 00000000000000..134499107ab2b7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst @@ -0,0 +1 @@ +Fix command quoting in :exc:`subprocess.CalledProcessError`. Contributed by Benjy Wiener.