From a7b506046e79da8a0fb476a91fa357112e8670a8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 1 Sep 2020 21:53:10 +0800 Subject: [PATCH] pybind/rados: define unicode alias for silencing warnings like: WARNING: Cannot resolve forward reference in type annotations of "rados.Rados.conf_get": name 'unicode' is not defined because cython < 3.0 with language_level = "3", translates "str" to "unicode" to be python2 compatible, but we've migrated to python3. and the specified "language_level" is "3'. see also https://github.com/cython/cython/issues/1370 Signed-off-by: Kefu Chai --- src/pybind/rados/rados.pyx | 2 ++ src/pybind/rados/setup.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index f9717000370a..d5096419ca34 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1869,6 +1869,8 @@ cdef class Snap(object): raise make_ex(ret, "rados_ioctx_snap_get_stamp error") return datetime.fromtimestamp(snap_time) +# https://github.com/cython/cython/issues/1370 +unicode = str cdef class Completion(object): """completion object""" diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index ca2581a0fe8f..5341ae992176 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -189,6 +189,7 @@ setup( **get_python_flags(['rados']) ) ], + # use "3str" when Cython 3.0 is available compiler_directives={'language_level': sys.version_info.major}, build_dir=os.environ.get("CYTHON_BUILD_DIR", None) ), -- 2.47.3