fixing a couple of unit-test failures that were being caused because the (python) code was passing strings instead of bytes
This commit is contained in:
parent
817976b48c
commit
2b50159ffe
@ -153,7 +153,18 @@ def toco_convert_protos(model_flags_str,
|
|||||||
fp_toco.write(toco_flags_str)
|
fp_toco.write(toco_flags_str)
|
||||||
fp_input.write(input_data_str)
|
fp_input.write(input_data_str)
|
||||||
debug_info_str = debug_info_str if debug_info_str else ""
|
debug_info_str = debug_info_str if debug_info_str else ""
|
||||||
fp_debug.write(debug_info_str)
|
# if debug_info_str contains a "string value", then the call to
|
||||||
|
# fp_debug.write(debug_info_str) will fail with the following error
|
||||||
|
#
|
||||||
|
# TypeError: a bytes-like object is required, not 'str'
|
||||||
|
#
|
||||||
|
# Some of the subtests within the "convert_test" unit-test fail
|
||||||
|
# with the error shown above. So watch out for that scenario and
|
||||||
|
# convert debug_info_str to bytes where needed
|
||||||
|
if isinstance(debug_info_str, str):
|
||||||
|
fp_debug.write(debug_info_str.encode('utf-8'))
|
||||||
|
else:
|
||||||
|
fp_debug.write(debug_info_str)
|
||||||
|
|
||||||
# Reserve an output file
|
# Reserve an output file
|
||||||
with _tempfile.NamedTemporaryFile(delete=False) as fp:
|
with _tempfile.NamedTemporaryFile(delete=False) as fp:
|
||||||
|
@ -99,8 +99,8 @@ class Delegate(object):
|
|||||||
options_keys = (ctypes.c_char_p * len(options))()
|
options_keys = (ctypes.c_char_p * len(options))()
|
||||||
options_values = (ctypes.c_char_p * len(options))()
|
options_values = (ctypes.c_char_p * len(options))()
|
||||||
for idx, (key, value) in enumerate(options.items()):
|
for idx, (key, value) in enumerate(options.items()):
|
||||||
options_keys[idx] = str(key)
|
options_keys[idx] = str(key).encode('utf-8')
|
||||||
options_values[idx] = str(value)
|
options_values[idx] = str(value).encode('utf-8')
|
||||||
|
|
||||||
class ErrorMessageCapture(object):
|
class ErrorMessageCapture(object):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user