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

login
register
mail settings
Submitter Augie Fackler
Date Aug. 1, 2017, 8:34 p.m.
Message ID <7aac6fefd0a1a7357fb4.1501619676@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/22617/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 1, 2017, 8:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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: