]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/rados: do not slice zip()
authorKefu Chai <kchai@redhat.com>
Tue, 22 Oct 2019 04:42:06 +0000 (12:42 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 22 Oct 2019 08:05:26 +0000 (16:05 +0800)
in python2, zip() returns a list. while in python3, zip() returns an
iterator. so we cannot slice the return value of zip(...) anymore. let's
just materialized the iterator before slicing it.

this change address the failure of
```
ERROR: test_rados.TestIoctx.test_applications
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in
runTest
    self.test(*self.arg)
  File "/var/ssd/ceph/src/test/pybind/test_rados.py", line 879, in
test_applications
    eq([], self.ioctx.application_metadata_list("app1"))
  File "rados.pyx", line 4074, in rados.Ioctx.application_metadata_list
TypeError: 'zip' object is unsliceable
```

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/rados/rados.pyx

index 6f4828b0be9af25dbe28fa6d62646e28d48d0548..8dc9f7e2dc6acb01de5486a988ee0a78371682be 100644 (file)
@@ -4071,7 +4071,7 @@ returned %d, but should return zero on success." % (self.name, ret))
                                 c_keys[:key_length].split(b'\0')]
                     vals = [decode_cstr(val) for val in
                                 c_vals[:val_length].split(b'\0')]
-                    return zip(keys, vals)[:-1]
+                    return list(zip(keys, vals))[:-1]
                 elif ret == -errno.ERANGE:
                     pass
                 else: