From 72ea5f4add89acd9e4dc905bca8df1b15a993925 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Wed, 12 Oct 2016 14:29:09 +0000
Subject: [PATCH] Task #9931: fix in handling multiline buffer

---
 LCS/PyCommon/subprocess.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/LCS/PyCommon/subprocess.py b/LCS/PyCommon/subprocess.py
index dfdb4aadf90..3d6d5ddc2b7 100644
--- a/LCS/PyCommon/subprocess.py
+++ b/LCS/PyCommon/subprocess.py
@@ -51,9 +51,10 @@ class PipeReader:
     def readlines(self, timeout=None):
         self.__fill_line_buffer(timeout)
 
-        lines = self.__line_buffer.split('\n')
-        if lines and not lines[-1].endswith('\n'):
-            self.__line_buffer = lines[-1]
-            lines = lines[:-2]
+        last_line_end_idx = self.__line_buffer.rfind('\n')
+        head = self.__line_buffer[:last_line_end_idx]
+        self.__line_buffer = self.__line_buffer[last_line_end_idx:]
+
+        lines = [l for l in head.split('\n') if l]
 
         return lines
-- 
GitLab