From: Kefu Chai Date: Sat, 23 Feb 2019 14:26:48 +0000 (+0800) Subject: pybind: encode flattened dict X-Git-Tag: v14.2.22~26^2~5^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f857c227ff78b9964fc3fd414beaea6b1ed97976;p=ceph.git pybind: encode flattened dict 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 (cherry picked from commit 6cb23f9ce6b3848a7fd93d135acc143f2ae7cba1) --- diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index dbd150540b67..b281ce69001b 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -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: