]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16550)
authorVictor Stinner <vstinner@python.org>
Wed, 2 Oct 2019 23:04:09 +0000 (01:04 +0200)
committerGitHub <noreply@github.com>
Wed, 2 Oct 2019 23:04:09 +0000 (01:04 +0200)
WindowsLoadTracker.read_output() now uses a short buffer for
incomplete line.

Lib/test/libregrtest/win_utils.py

index f0c17b906f51923f581f4adb42a883c8ff4247a8..f802980c20b5c45e6917f013d93e1e1591da3c5e 100644 (file)
@@ -32,6 +32,7 @@ class WindowsLoadTracker():
     def __init__(self):
         self.load = 0.0
         self.counter_name = ''
+        self._buffer = b''
         self.popen = None
         self.start()
 
@@ -100,7 +101,9 @@ class WindowsLoadTracker():
         if res != 0:
             return
 
-        output = overlapped.getbuffer()
+        # self._buffer stores an incomplete line
+        output = self._buffer + overlapped.getbuffer()
+        output, _, self._buffer = output.rpartition(b'\n')
         return output.decode('oem', 'replace')
 
     def getloadavg(self):