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:
Edward Loper 2019-07-24 20:30:38 -07:00 committed by TensorFlower Gardener
parent 85ccca4ad1
commit 97029c72c7
2 changed files with 1 additions and 2 deletions

View File

@ -111,7 +111,6 @@ py_test(
srcs = ["lite_v2_test.py"],
srcs_version = "PY2AND3",
tags = [
"no_oss",
"no_windows",
],
deps = [

View File

@ -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)