Fix bug in ConvertPyObjectToAttributeType when type="tensor" and value is a string that's not a Tensor textproto.
PiperOrigin-RevId: 325892441 Change-Id: I4a29954ec32b84fef75859ac36f4e694a0317688
This commit is contained in:
parent
6411114cbd
commit
dd2ee4e8cc
@ -167,8 +167,10 @@ struct ConvertTensorProtoFunctor {
|
||||
} else if (PY_STRING_CHECK(value)) {
|
||||
result.reset(PyObject_CallObject(tensor_proto, nullptr));
|
||||
if (result) {
|
||||
PyObject_CallFunctionObjArgs(text_format_parse, value, result.get(),
|
||||
nullptr);
|
||||
if (!PyObject_CallFunctionObjArgs(text_format_parse, value,
|
||||
result.get(), nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -87,6 +87,7 @@ class OpDefUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase):
|
||||
("list(any)", 12),
|
||||
("list(int)", [1, "two"]),
|
||||
("list(string)", [1, "two"]),
|
||||
("tensor", "string that is not a text-formatted TensorProto"),
|
||||
])
|
||||
def testConvertError(self, attr_type, value):
|
||||
with self.assertRaisesRegex(TypeError, "Failed to convert value"):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user