From f1de81d9f00ce55c8a1c4795391692c066f6472d Mon Sep 17 00:00:00 2001 From: Benjy Wiener Date: Mon, 15 Jun 2026 09:59:27 +0300 Subject: [PATCH 1/2] Fix command quoting in CalledProcessError CalledProcessError previously formatted cmd as `"... '%s' ..."`. This lead to unbalanced quoting when cmd contains single-quotes or, more commonly, when cmd is a list. This change updates the relevant format strings to use %r instead. --- Lib/subprocess.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 38b655f2f7b9d2b..6fe2ec98fb40888 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 From 7c2bb0493200146012e0acd8b9f681f6bad47184 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 07:42:14 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2026-06-15-07-42-12.gh-issue-151485.NiYQPZ.rst 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 000000000000000..134499107ab2b78 --- /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.