diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py index 4beab0fe5a1..53f6a563192 100644 --- a/Lib/packaging/tests/test_util.py +++ b/Lib/packaging/tests/test_util.py @@ -74,6 +74,9 @@ def __init__(self, args, bufsize=0, executable=None, self.stdout = StringIO(exes[self.cmd]) self.stderr = StringIO() + def communicate(self, input=None, timeout=None): + return self.stdout.read(), self.stderr.read() + class UtilTestCase(support.EnvironRestorer, support.TempdirManager, diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py index 71ce819af01..bf31c31be62 100644 --- a/Lib/packaging/util.py +++ b/Lib/packaging/util.py @@ -464,7 +464,7 @@ def _find_exe_version(cmd, pattern=_RE_VERSION): return None pipe = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) try: - stdout, stderr = pipe.stdout.read(), pipe.stderr.read() + stdout, stderr = pipe.communicate() finally: pipe.stdout.close() pipe.stderr.close()