diff mercurial/util.py @ 38314:565074cc9ac6

tests: suppress read(-1) -> '' calls in fileobjectobserver This stabilizes the test output of the low-level wireproto tests between Python 2 and 3. I don't feel great about this change, but otherwise we get a ton of extra read(-1) output on Python 3, and this feels like a more sustainable solution. Bonus: test-ssh-proto-unbundle.t now passes on Python 3. Differential Revision: https://phab.mercurial-scm.org/D3733
author Augie Fackler <augie@google.com>
date Thu, 14 Jun 2018 11:49:10 -0400
parents aac4be30e250
children 63e6f5ae84bc
line wrap: on
line diff
--- a/mercurial/util.py	Thu Jun 14 11:47:51 2018 -0400
+++ b/mercurial/util.py	Thu Jun 14 11:49:10 2018 -0400
@@ -782,6 +782,13 @@
         if res is None:
             res = ''
 
+        if size == -1 and res == '':
+            # Suppress pointless read(-1) calls that return
+            # nothing. These happen _a lot_ on Python 3, and there
+            # doesn't seem to be a better workaround to have matching
+            # Python 2 and 3 behavior. :(
+            return
+
         if self.logdataapis:
             self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res)))