From 36af6f66de4722b30f5e8a960e5791f3a8ad2a16 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Tue, 26 May 2020 13:39:24 +0530 Subject: [PATCH] Assert proc.stdin and proc.stdout --- src/pip/_internal/utils/subprocess.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/utils/subprocess.py b/src/pip/_internal/utils/subprocess.py index bdebaef7827..d93801b2ac4 100644 --- a/src/pip/_internal/utils/subprocess.py +++ b/src/pip/_internal/utils/subprocess.py @@ -185,8 +185,9 @@ def call_subprocess( stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd, env=env, ) - if proc.stdin: - proc.stdin.close() + assert proc.stdin + assert proc.stdout + proc.stdin.close() except Exception as exc: if log_failed_cmd: subprocess_logger.critical( @@ -196,9 +197,7 @@ def call_subprocess( all_output = [] while True: # The "line" value is a unicode string in Python 2. - line = None - if proc.stdout: - line = console_to_str(proc.stdout.readline()) + line = console_to_str(proc.stdout.readline()) if not line: break line = line.rstrip()