From 23ad1d6db7ec8116afed7c8aca3832dac440930a Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Wed, 19 Feb 2014 03:12:33 +0100 Subject: [PATCH] Python3: define a __next__() method for VerboseIteratorWrapper In Python 3, __next__() has replaced next(). Also, call the next() function rather than the next() method. Closes-Bug: #1281866 Change-Id: I92b44508c9c875f16ad89ef8410d2c38092ab23d --- glanceclient/common/progressbar.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glanceclient/common/progressbar.py b/glanceclient/common/progressbar.py index 8b2b703e..cd4ffe50 100644 --- a/glanceclient/common/progressbar.py +++ b/glanceclient/common/progressbar.py @@ -15,6 +15,8 @@ import sys +import six + class _ProgressBarBase(object): """ @@ -78,7 +80,7 @@ class VerboseIteratorWrapper(_ProgressBarBase): def next(self): try: - data = self._wrapped.next() + data = six.next(self._wrapped) # NOTE(mouad): Assuming that data is a string b/c otherwise calling # len function will not make any sense. self._display_progress_bar(len(data)) @@ -89,3 +91,6 @@ class VerboseIteratorWrapper(_ProgressBarBase): # output. sys.stdout.write('\n') raise + + # In Python 3, __next__() has replaced next(). + __next__ = next