procutil: avoid `+= None` when writing to full std{err,out} descriptor on py3 stable
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 13 Apr 2022 14:46:22 -0400
branchstable
changeset 49068 90e564882f07
parent 49067 770e1352e9f9
child 49084 ea98850a136e
child 49145 dd2503a63d33
procutil: avoid `+= None` when writing to full std{err,out} descriptor on py3 The write function returns `None` if there was no room to write the given data[1]. I don't like that this is effectively an infinite loop if there's never any progress emptying the underlying buffer, but we're no worse off than before, and it fixes random stacktrace popups seen in the py3 build of TortoiseHg. [1] https://docs.python.org/3/library/io.html#io.RawIOBase.write Differential Revision: https://phab.mercurial-scm.org/D12555
mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py	Mon Apr 18 20:45:38 2022 -0700
+++ b/mercurial/utils/procutil.py	Wed Apr 13 14:46:22 2022 -0400
@@ -112,7 +112,9 @@
         total_to_write = len(s)
         total_written = 0
         while total_written < total_to_write:
-            total_written += write1(m[total_written:])
+            c = write1(m[total_written:])
+            if c:
+                total_written += c
         return total_written