comparison mercurial/bundle2.py @ 33673:5ae35a1347fd

bundle2: look for __next__ as well as next to identify iterators In Python 3, next is called __next__ and this was failing to catch some iterators.
author Augie Fackler <augie@google.com>
date Mon, 24 Jul 2017 11:19:45 -0400
parents da7c285ec6da
children 9a323773216c
comparison
equal deleted inserted replaced
33672:da7c285ec6da 33673:5ae35a1347fd
1068 """yield chunks of a the part payload 1068 """yield chunks of a the part payload
1069 1069
1070 Exists to handle the different methods to provide data to a part.""" 1070 Exists to handle the different methods to provide data to a part."""
1071 # we only support fixed size data now. 1071 # we only support fixed size data now.
1072 # This will be improved in the future. 1072 # This will be improved in the future.
1073 if util.safehasattr(self.data, 'next'): 1073 if (util.safehasattr(self.data, 'next')
1074 or util.safehasattr(self.data, '__next__')):
1074 buff = util.chunkbuffer(self.data) 1075 buff = util.chunkbuffer(self.data)
1075 chunk = buff.read(preferedchunksize) 1076 chunk = buff.read(preferedchunksize)
1076 while chunk: 1077 while chunk:
1077 yield chunk 1078 yield chunk
1078 chunk = buff.read(preferedchunksize) 1079 chunk = buff.read(preferedchunksize)