[Python-checkins] bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16550)

Victor Stinner webhook-mailer at python.org
Wed Oct 2 19:04:13 EDT 2019


https://github.com/python/cpython/commit/3e04cd268ee9a57f95dc78d8974b21a6fac3f666
commit: 3e04cd268ee9a57f95dc78d8974b21a6fac3f666
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2019-10-03T01:04:09+02:00
summary:

bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16550)

WindowsLoadTracker.read_output() now uses a short buffer for
incomplete line.

files:
M Lib/test/libregrtest/win_utils.py

diff --git a/Lib/test/libregrtest/win_utils.py b/Lib/test/libregrtest/win_utils.py
index f0c17b906f519..f802980c20b5c 100644
--- a/Lib/test/libregrtest/win_utils.py
+++ b/Lib/test/libregrtest/win_utils.py
@@ -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 @@ def read_output(self):
         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):



More information about the Python-checkins mailing list