Patchwork D2561: util: work around Python 3 returning None at EOF instead of ''

login
register
mail settings
Submitter phabricator
Date March 2, 2018, 8:04 p.m.
Message ID <differential-rev-PHID-DREV-wjcr2zmuu4nk4kcbwfjt-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28716/
State Superseded
Headers show

Comments

phabricator - March 2, 2018, 8:04 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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)