]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/rados: define unicode alias
authorKefu Chai <kchai@redhat.com>
Tue, 1 Sep 2020 13:53:10 +0000 (21:53 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 Sep 2020 16:30:55 +0000 (00:30 +0800)
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 <kchai@redhat.com>
src/pybind/rados/rados.pyx
src/pybind/rados/setup.py

index f9717000370a305199b4007e4a5b0c81ba92a9f5..d5096419ca342ddfbfae933f1553ddc537719856 100644 (file)
@@ -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"""
index ca2581a0fe8f8e1d0b2e5b46b6bf87e09e99cd85..5341ae992176f682b979e2fcc04c0b239b029c64 100755 (executable)
@@ -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)
     ),