util: work around Python 3 returning None at EOF instead of ''
authorAugie Fackler <augie@google.com>
Fri, 02 Mar 2018 14:09:50 -0500
changeset 36585 26a6b62919e2
parent 36584 f5427483eebe
child 36586 ff6b8484400b
util: work around Python 3 returning None at EOF instead of '' Differential Revision: https://phab.mercurial-scm.org/D2561
mercurial/util.py
--- a/mercurial/util.py	Fri Mar 02 14:09:20 2018 -0500
+++ b/mercurial/util.py	Fri Mar 02 14:09:50 2018 -0500
@@ -729,6 +729,9 @@
     def read(self, res, size=-1):
         if not self.reads:
             return
+        # Python 3 can return None from reads at EOF instead of empty strings.
+        if res is None:
+            res = ''
 
         self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res)))
         self._writedata(res)