Fix next issue for Python 2/3 compatible code.
change x.next() to next(x) and add __next__() for class Story: 2003430 Task: 26519 Change-Id: I4cda6f1d679e05b7f533b94840e0eb561213aa76 Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
eb6a4cae4e
commit
f2a6d355a9
|
@ -74,9 +74,12 @@ class ModelBase(object):
|
|||
return self
|
||||
|
||||
def next(self):
|
||||
n = self._i.next()
|
||||
n = next(self._i)
|
||||
return n, getattr(self, n)
|
||||
|
||||
# In Python 3, __next__() has replaced next().
|
||||
__next__ = next
|
||||
|
||||
def update(self, values):
|
||||
"""Make the model object behave like a dict."""
|
||||
for k, v in values.items():
|
||||
|
|
|
@ -556,7 +556,7 @@ class MulticallWaiter(object):
|
|||
raise StopIteration
|
||||
while True:
|
||||
try:
|
||||
self._iterator.next()
|
||||
next(self._iterator)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self.done()
|
||||
|
|
|
@ -616,7 +616,7 @@ class Connection(object):
|
|||
|
||||
def _declare_consumer():
|
||||
consumer = consumer_cls(self.conf, self.channel, topic, callback,
|
||||
self.consumer_num.next())
|
||||
next(self.consumer_num))
|
||||
self.consumers.append(consumer)
|
||||
return consumer
|
||||
|
||||
|
@ -722,7 +722,7 @@ class Connection(object):
|
|||
it = self.iterconsume(limit=limit)
|
||||
while True:
|
||||
try:
|
||||
it.next()
|
||||
next(it)
|
||||
except StopIteration:
|
||||
return
|
||||
|
||||
|
|
|
@ -520,7 +520,7 @@ class Connection(object):
|
|||
it = self.iterconsume(limit=limit)
|
||||
while True:
|
||||
try:
|
||||
it.next()
|
||||
next(it)
|
||||
except StopIteration:
|
||||
return
|
||||
|
||||
|
|
|
@ -558,8 +558,8 @@ def unflatten_envelope(packenv):
|
|||
h = {}
|
||||
try:
|
||||
while True:
|
||||
k = i.next()
|
||||
h[k] = i.next()
|
||||
k = next(i)
|
||||
h[k] = next(i)
|
||||
except StopIteration:
|
||||
return h
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ class ResponseBodyIterator(object):
|
|||
|
||||
def __iter__(self):
|
||||
while True:
|
||||
yield self.next()
|
||||
yield next(self)
|
||||
|
||||
def next(self):
|
||||
chunk = self.resp.read(CHUNKSIZE)
|
||||
|
@ -300,3 +300,6 @@ class ResponseBodyIterator(object):
|
|||
return chunk
|
||||
else:
|
||||
raise StopIteration()
|
||||
|
||||
# In Python 3, __next__() has replaced next().
|
||||
__next__ = next
|
||||
|
|
Loading…
Reference in New Issue