Skip to content

Commit

Permalink
Simplify _to_string encoding of Python strs
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Oct 16, 2024
1 parent 22668fa commit 1a16da1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/kvikio/kvikio/_lib/remote_handle.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ cdef extern from "<kvikio/remote_handle.hpp>" 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:
Expand Down

0 comments on commit 1a16da1

Please sign in to comment.