From 7244bef734d06f17b116bddfc12a22b8286b2914 Mon Sep 17 00:00:00 2001 From: Caihui Date: Tue, 30 Jun 2020 19:06:37 -0700 Subject: [PATCH] Update ReSizeSteam.next() to ReSizeSteam__next__() 1. The bug. ~~~~~~~~~~~~~~~~~~~ Traceback (most recent call last): File "/opt/stack/freezer/freezer/tests/unit/openstack/test_backup.py", line 37, in test_backup_cinder_by_glance self.bakup_os.backup_cinder_by_glance(35) File "/opt/stack/freezer/freezer/openstack/backup.py", line 79, in backup_cinder_by_glance self.storage.add_stream(stream, package, headers=headers) File "/opt/stack/freezer/freezer/storage/swift.py", line 163, in add_stream for el in stream: TypeError: iter() returned non-iterator of type 'ReSizeStream' 2. Fix In python3.x , a iterator object should be difined two funs " __iter__()" and "__next__()". Update ReSizeSteam.next() to ReSizeSteam.__next__(). Change-Id: I940841b94789d024d3b9447f96158963fe3e16ee --- freezer/tests/unit/openstack/test_backup.py | 4 ---- freezer/utils/utils.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/freezer/tests/unit/openstack/test_backup.py b/freezer/tests/unit/openstack/test_backup.py index 4c3cc80e..c5977bda 100644 --- a/freezer/tests/unit/openstack/test_backup.py +++ b/freezer/tests/unit/openstack/test_backup.py @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import sys -import unittest from freezer.openstack import backup from freezer.tests import commons @@ -31,8 +29,6 @@ class TestBackup(commons.FreezerBaseTestCase): self.client_manager = self.backup_opt.client_manager self.storage = self.backup_opt.storage - @unittest.skipIf(sys.version_info.major == 3, - 'Not supported on python v 3.x') def test_backup_cinder_by_glance(self): self.bakup_os.backup_cinder_by_glance(35) diff --git a/freezer/utils/utils.py b/freezer/utils/utils.py index 29b3f05e..1b3d1a14 100644 --- a/freezer/utils/utils.py +++ b/freezer/utils/utils.py @@ -263,7 +263,7 @@ class ReSizeStream(object): def __iter__(self): return self - def next(self): + def __next__(self): LOG.debug("Transmitted {0} of {1}".format(self.transmitted, self.length)) chunk_size = self.chunk_size