From b4fc44bb2d209182390b4f9fdf074a46b0165a2f Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Thu, 11 Mar 2021 13:43:29 -0600 Subject: bpo-43423 Fix IndexError in subprocess _communicate function (GH-24777) Check to make sure stdout and stderr are not empty before selecting an item from them in Windows subprocess._communicate. Co-authored-by: Gregory P. Smith --- Lib/subprocess.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Lib/subprocess.py') diff --git a/Lib/subprocess.py b/Lib/subprocess.py index e4ca5f500c..d375514b2d 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1535,10 +1535,8 @@ class Popen(object): self.stderr.close() # All data exchanged. Translate lists into strings. - if stdout is not None: - stdout = stdout[0] - if stderr is not None: - stderr = stderr[0] + stdout = stdout[0] if stdout else None + stderr = stderr[0] if stderr else None return (stdout, stderr) -- cgit v1.2.1