diff --git a/mindspore/_extends/parse/standard_method.py b/mindspore/_extends/parse/standard_method.py index d06ba8fa56924a4519720d6d2765dc6f5c4c742b..d70c6edcf472023ed9a09a669627ae1e229da0b4 100644 --- a/mindspore/_extends/parse/standard_method.py +++ b/mindspore/_extends/parse/standard_method.py @@ -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): """check whether x is const int.""" 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): - 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 diff --git a/tests/ut/python/pipeline/parse/test_enumerate.py b/tests/ut/python/pipeline/parse/test_enumerate.py index c6d4e08b7dcfea0fd014f30a8770993e5e160516..37f9c603dfdf4abca5ee86e8dae035bff614d496 100644 --- a/tests/ut/python/pipeline/parse/test_enumerate.py +++ b/tests/ut/python/pipeline/parse/test_enumerate.py @@ -196,6 +196,6 @@ def test_enumerate_start_type_error(): x = Tensor(np.arange(3 * 4 * 5).reshape((3, 4, 5))) net = Net() - with pytest.raises(ValueError) as ex: + with pytest.raises(TypeError) as ex: net((x, x)) assert "For 'enumerate', the 'start'" in str(ex.value)