Skip to content

Commit f1de81d

Browse files
author
Benjy Wiener
committed
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.
1 parent d63c994 commit f1de81d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/subprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
145145
def __str__(self):
146146
if self.returncode and self.returncode < 0:
147147
try:
148-
return "Command '%s' died with %r." % (
148+
return "Command %r died with %r." % (
149149
self.cmd, signal.Signals(-self.returncode))
150150
except ValueError:
151-
return "Command '%s' died with unknown signal %d." % (
151+
return "Command %r died with unknown signal %d." % (
152152
self.cmd, -self.returncode)
153153
else:
154-
return "Command '%s' returned non-zero exit status %d." % (
154+
return "Command %r returned non-zero exit status %d." % (
155155
self.cmd, self.returncode)
156156

157157
@property

0 commit comments

Comments
 (0)