Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
38313:275cc461b854 | 38314:565074cc9ac6 |
---|---|
779 if not self.reads: | 779 if not self.reads: |
780 return | 780 return |
781 # Python 3 can return None from reads at EOF instead of empty strings. | 781 # Python 3 can return None from reads at EOF instead of empty strings. |
782 if res is None: | 782 if res is None: |
783 res = '' | 783 res = '' |
784 | |
785 if size == -1 and res == '': | |
786 # Suppress pointless read(-1) calls that return | |
787 # nothing. These happen _a lot_ on Python 3, and there | |
788 # doesn't seem to be a better workaround to have matching | |
789 # Python 2 and 3 behavior. :( | |
790 return | |
784 | 791 |
785 if self.logdataapis: | 792 if self.logdataapis: |
786 self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res))) | 793 self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res))) |
787 | 794 |
788 self._writedata(res) | 795 self._writedata(res) |