comparison mercurial/util.py @ 36585:26a6b62919e2

util: work around Python 3 returning None at EOF instead of '' Differential Revision: https://phab.mercurial-scm.org/D2561
author Augie Fackler <augie@google.com>
date Fri, 02 Mar 2018 14:09:50 -0500
parents f5427483eebe
children 281f66777ff0
comparison
equal deleted inserted replaced
36584:f5427483eebe 36585:26a6b62919e2
727 self.fh.write('%s> %s\n' % (self.name, escapedata(line))) 727 self.fh.write('%s> %s\n' % (self.name, escapedata(line)))
728 728
729 def read(self, res, size=-1): 729 def read(self, res, size=-1):
730 if not self.reads: 730 if not self.reads:
731 return 731 return
732 # Python 3 can return None from reads at EOF instead of empty strings.
733 if res is None:
734 res = ''
732 735
733 self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res))) 736 self.fh.write('%s> read(%d) -> %d' % (self.name, size, len(res)))
734 self._writedata(res) 737 self._writedata(res)
735 738
736 def readline(self, res, limit=-1): 739 def readline(self, res, limit=-1):