diff --git a/python/kvikio/kvikio/_lib/remote_handle.pyx b/python/kvikio/kvikio/_lib/remote_handle.pyx index 5e58da32f0..93c6ac398a 100644 --- a/python/kvikio/kvikio/_lib/remote_handle.pyx +++ b/python/kvikio/kvikio/_lib/remote_handle.pyx @@ -40,11 +40,13 @@ cdef extern from "" nogil: size_t file_offset ) except + -cdef string _to_string(str_or_none): + +cdef string _to_string(str s): """Convert Python object to a C++ string (if None, return the empty string)""" - if str_or_none is None: + if s is not None: + return s.encode() + else: return string() - return str.encode(str(str_or_none)) cdef class RemoteFile: