summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorChris Griffith <chris@cdgriffith.com>2021-03-11 19:43:29 (GMT)
committerGitHub <noreply@github.com>2021-03-11 19:43:29 (GMT)
commitb4fc44bb2d209182390b4f9fdf074a46b0165a2f (patch)
tree91fce7c1d25326301e9433f8f15d9dadf97b1b72 /Lib/subprocess.py
parent87f649a409da9d99682e78a55a83fc43225a8729 (diff)
downloadcpython-b4fc44bb2d209182390b4f9fdf074a46b0165a2f.zip
cpython-b4fc44bb2d209182390b4f9fdf074a46b0165a2f.tar.gz
cpython-b4fc44bb2d209182390b4f9fdf074a46b0165a2f.tar.bz2
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 <greg@krypto.org>
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index e4ca5f5..d375514 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)