]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: encode flattened dict
authorKefu Chai <kchai@redhat.com>
Sat, 23 Feb 2019 14:26:48 +0000 (22:26 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 5 May 2021 06:32:25 +0000 (14:32 +0800)
in python3, the keys and values in dict are unicode strings, so we need
to encode them before passing them to underlying librados' C API.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 6cb23f9ce6b3848a7fd93d135acc143f2ae7cba1)

src/pybind/rados/rados.pyx

index dbd150540b67d6f58df4694d983ba9d96bcd3ecc..b281ce69001bec6fa8b9fabd44649fb9aec4acb6 100644 (file)
@@ -559,7 +559,7 @@ def decode_cstr(val, encoding="utf-8"):
 
 def flatten_dict(d):
     items = chain.from_iterable(d.items())
-    return ''.join(i + '\0' for i in items)
+    return cstr(''.join(i + '\0' for i in items))
 
 
 cdef char* opt_str(s) except? NULL: