Skip to content

Commit

Permalink
Improve string handling in Python bindings of ControllerClient.
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Gergondet <[email protected]>
  • Loading branch information
mmurooka and gergondet committed Aug 15, 2023
1 parent 46ea4d0 commit b44c05a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion binding/python/mc_control/mc_control.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ cdef class MCGlobalController(object):

cdef class ElementId(object):
def __cinit__(self, category, name):
self.impl = c_mc_control.ElementId(category, name)
if isinstance(name, unicode):
name = name.encode(u'ascii')
self.impl = c_mc_control.ElementId([s.encode(u'ascii') if isinstance(s, unicode) else s for s in category] , name)
property category:
def __get__(self):
return self.impl.category
Expand All @@ -382,6 +384,10 @@ cdef class ElementId(object):

cdef class ControllerClient(object):
def __cinit__(self, sub_conn_uri, push_conn_uri, timeout = 0.0):
if isinstance(sub_conn_uri, unicode):
sub_conn_uri = sub_conn_uri.encode(u'ascii')
if isinstance(push_conn_uri, unicode):
push_conn_uri = push_conn_uri.encode(u'ascii')
self.impl = new c_mc_control.ControllerClient(sub_conn_uri, push_conn_uri, timeout)
def send_request(self, element_id, data = None):
if data is None:
Expand Down

0 comments on commit b44c05a

Please sign in to comment.