dimanche 3 juillet 2016

Ctypes: TypeError: can't concat bytes to str

Looking at other stackoverflow solutions to same error and they either are different than my issue or the answer is not very clear. If you can help, please give a detailed explanation to help me understand.

Functions being called in python3.5:

plist = StreamingParameterList()
plist = [plist[x] for x in [2,4,12,13,14]]
set_parameter_list(plist)

code of functions:

def StreamingParameterList():
""" returns a list of all available streaming parameter names """
num, length = get_parameter_list_size()
splist = []
for id in range(num):
    splist.append(get_parameter_list_item(id, length)[0])

return splist


def set_parameter_list(namelist):
""" sets the list of parameters to stream """
f = shim.set_parameter_list
num, strlen = get_parameter_list_size()
namecount = ct.c_short(len(namelist))
delimitednames = [(name+'x00').ljust(strlen) for name in namelist]
cnames = ct.c_char_p(''.join(delimitednames))

result = f(namecount, cnames)

error:

delimitednames = [(name+'x00').ljust(strlen) for name in namelist]

TypeError: can't concat bytes to str

Aucun commentaire:

Enregistrer un commentaire