Refuse resolve node to generate interpreted object

This commit is contained in:
liangzhibo 2022-09-24 10:14:48 +08:00
parent 079be33551
commit deb8a1a5d9
2 changed files with 8 additions and 1 deletions

View File

@ -270,6 +270,13 @@ AnfNodePtr ConvertObjectToNode(const AnfNodePtr &origin_node, const py::object &
MS_LOG(ERROR) << "Convert data failed";
return nullptr;
}
bool interpret_without_internal =
(IsPrimitiveCNode(origin_node, prim::kPrimPyInterpret) && !origin_node->interpret_internal_type()) ||
origin_node->interpret();
if (!interpret_without_internal && convert_result->isa<InterpretedObject>()) {
auto type_str = python_adapter::CallPyFn(parse::PYTHON_MOD_PARSE_MODULE, parse::PYTHON_PARSE_GET_TYPE, obj);
MS_EXCEPTION(TypeError) << "Do not support to convert " << py::str(type_str) << " into graph node.";
}
MS_EXCEPTION_IF_NULL(convert_result);
if (convert_result->isa<FuncGraph>() && has_recompute_scope) {
UpdateDebugInfo(convert_result->cast<FuncGraphPtr>(), origin_node->scope(), origin_node->debug_info());

View File

@ -44,7 +44,7 @@ def test_catch_exception_stack_trace_log():
assert os.path.exists(log_file_name)
with open(log_file_name, "r") as f_first:
data_first = f_first.read()
assert "Do not support to get attribute" in data_first
assert "Do not support to convert" in data_first
assert "x = self.y.tt1" in data_first
# Clean files