Patchwork D12555: procutil: avoid `+= None` when writing to full std{err, out} descriptor on py3

login
register
mail settings
Submitter phabricator
Date April 13, 2022, 10:48 p.m.
Message ID <differential-rev-PHID-DREV-q3vrxhi77fqntyj7tpip-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50903/
State New
Headers show

Comments

phabricator - April 13, 2022, 10:48 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12555

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -111,7 +111,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