summaryrefslogtreecommitdiff
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-03-11 17:56:35 -0800
committerGitHub <noreply@github.com>2021-03-11 17:56:35 -0800
commitad83fde75463dad2df878ff264f52436eb48bc6b (patch)
treebf20afe531a3433061f691c56d8b3454fdfef014 /Lib/subprocess.py
parent531f2ebd60a662111c78107935d249d3d52f9a4f (diff)
downloadcpython-git-ad83fde75463dad2df878ff264f52436eb48bc6b.tar.gz
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> (cherry picked from commit b4fc44bb2d209182390b4f9fdf074a46b0165a2f) Co-authored-by: Chris Griffith <chris@cdgriffith.com>
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 ddf1128fdd..0311e3a1f8 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1525,10 +1525,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)