提交 3e691e54 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!3071 change ValueError to TypeError for enumerate start

Merge pull request !3071 from zhangbuxue/change_ValueError_to_TypeError_for_enumerate_start
...@@ -135,9 +135,9 @@ def check_is_tuple_or_list(x, op_name, arg_name): ...@@ -135,9 +135,9 @@ def check_is_tuple_or_list(x, op_name, arg_name):
def check_is_const_int(x, op_name, arg_name): def check_is_const_int(x, op_name, arg_name):
"""check whether x is const int.""" """check whether x is const int."""
if x is None: if x is None:
raise ValueError(f"For '{op_name}', the '{arg_name}' should be a const int number, but got not const.") raise TypeError(f"For '{op_name}', the '{arg_name}' should be a const int number, but got not const.")
if not isinstance(x, int): if not isinstance(x, int):
raise ValueError(f"For '{op_name}', the '{arg_name}' should be a const int number, but got {x}.") raise TypeError(f"For '{op_name}', the '{arg_name}' should be a const int number, but got {x}.")
return True return True
......
...@@ -196,6 +196,6 @@ def test_enumerate_start_type_error(): ...@@ -196,6 +196,6 @@ def test_enumerate_start_type_error():
x = Tensor(np.arange(3 * 4 * 5).reshape((3, 4, 5))) x = Tensor(np.arange(3 * 4 * 5).reshape((3, 4, 5)))
net = Net() net = Net()
with pytest.raises(ValueError) as ex: with pytest.raises(TypeError) as ex:
net((x, x)) net((x, x))
assert "For 'enumerate', the 'start'" in str(ex.value) assert "For 'enumerate', the 'start'" in str(ex.value)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册