From c5a987d30728a4861c1137f185a8d17bb2246f01 Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Tue, 18 Feb 2025 15:45:32 +0300 Subject: [PATCH] Append subprocess stderr in CalledProcessError.__str__() --- Lib/subprocess.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 749c728db729ae..ac1fcc449fc14c 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -145,14 +145,14 @@ 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." % ( - self.cmd, signal.Signals(-self.returncode)) + return "Command '%s' died with %r:\n%s" % ( + self.cmd, signal.Signals(-self.returncode), self.stderr) except ValueError: - return "Command '%s' died with unknown signal %d." % ( - self.cmd, -self.returncode) + return "Command '%s' died with unknown signal %d:\n%s" % ( + self.cmd, -self.returncode, self.stderr) else: - return "Command '%s' returned non-zero exit status %d." % ( - self.cmd, self.returncode) + return "Command '%s' returned non-zero exit status %d:\n%s" % ( + self.cmd, self.returncode, self.stderr) @property def stdout(self):