From c459906491c1d4dd72557f75a7a1c36274979282 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Wed, 22 Jan 2025 20:46:29 -0400 Subject: [PATCH] Set cython language level to 3 Otherwise it fails to convert unicode to 'str': ``` Error compiling Cython file: ------------------------------------------------------------ ... if metadata_request_timeout is None: return stmt ms = int(metadata_request_timeout / datetime.timedelta(milliseconds=1)) if ms == 0: return stmt return f"{stmt} USING TIMEOUT {ms}ms" ^ ------------------------------------------------------------ cassandra/util.py:1813:11: Cannot convert Unicode string to 'str' implicitly. This is not portable and requires explicit encoding. ``` --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 538cee9ae..62c18b501 100644 --- a/setup.py +++ b/setup.py @@ -330,10 +330,15 @@ def _setup_extensions(self): extra_compile_args=compile_args) for m in cython_candidates], nthreads=build_concurrency, - exclude_failures=not CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST)) + exclude_failures=not CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST, + compiler_directives={'language_level': 3}, + )) - self.extensions.extend(cythonize(NoPatchExtension("*", ["cassandra/*.pyx"], extra_compile_args=compile_args), - nthreads=build_concurrency)) + self.extensions.extend(cythonize( + NoPatchExtension("*", ["cassandra/*.pyx"], extra_compile_args=compile_args), + nthreads=build_concurrency, + compiler_directives={'language_level': 3}, + )) except Exception: sys.stderr.write("Failed to cythonize one or more modules. These will not be compiled as extensions (optional).\n") if CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST: