[PATCH 08 of 10 py3] bundle2: look for __next__ as well as next to identify iterators

Augie Fackler raf at durin42.com
Tue Aug 1 16:34:36 EDT 2017


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1500909585 14400
#      Mon Jul 24 11:19:45 2017 -0400
# Node ID 7aac6fefd0a1a7357fb4f04b92e50131768b3f6b
# Parent  89d7a53b500a213396ab3c8e043a31dc5538ccaf
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.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1048,7 +1048,8 @@ class bundlepart(object):
         Exists to handle the different methods to provide data to a part."""
         # we only support fixed size data now.
         # This will be improved in the future.
-        if util.safehasattr(self.data, 'next'):
+        if (util.safehasattr(self.data, 'next')
+            or util.safehasattr(self.data, '__next__')):
             buff = util.chunkbuffer(self.data)
             chunk = buff.read(preferedchunksize)
             while chunk:


More information about the Mercurial-devel mailing list