Fix type-checking bug from PR #30615. That PR checked if a value was a unicode string using isinstance(debug_info_str, str). But in Python 2.x, str
is the byte-string type. So check against bytes
instead.
PiperOrigin-RevId: 259873125
This commit is contained in:
parent
85ccca4ad1
commit
97029c72c7
@ -111,7 +111,6 @@ py_test(
|
||||
srcs = ["lite_v2_test.py"],
|
||||
srcs_version = "PY2AND3",
|
||||
tags = [
|
||||
"no_oss",
|
||||
"no_windows",
|
||||
],
|
||||
deps = [
|
||||
|
@ -161,7 +161,7 @@ def toco_convert_protos(model_flags_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):
|
||||
if not isinstance(debug_info_str, bytes):
|
||||
fp_debug.write(debug_info_str.encode("utf-8"))
|
||||
else:
|
||||
fp_debug.write(debug_info_str)
|
||||
|
Loading…
Reference in New Issue
Block a user