From 6e5c3d7f07ad651202328aa41682938e01319bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Thu, 14 Sep 2023 19:27:32 +0200 Subject: [PATCH] make subprocess_readlines more robust --- pydiffchecker/helper.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pydiffchecker/helper.py b/pydiffchecker/helper.py index f9d4e08..6a6c214 100644 --- a/pydiffchecker/helper.py +++ b/pydiffchecker/helper.py @@ -3,14 +3,13 @@ from typing import Iterator def subprocess_readlines(cmd, cwd=None) -> Iterator[str]: - process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE) + process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, text=True) for line in process.stdout: - line = line.decode().rstrip(r'\n') - + line = line.rstrip('\n') yield line - process.wait() + process.communicate() if process.returncode != 0: raise subprocess.CalledProcessError(process.returncode, cmd)