From a2640014bc210eda2e067c4c51e822707ea7ecb6 Mon Sep 17 00:00:00 2001 From: haosenwang1018 <167664334+haosenwang1018@users.noreply.github.com> Date: Thu, 26 Feb 2026 01:53:50 +0000 Subject: [PATCH] fix: replace 6 bare except clauses with except Exception --- python/tvm/relax/frontend/torch/fx_translator.py | 2 +- python/tvm/runtime/_tensor.py | 2 +- python/tvm/s_tir/dlight/analysis/common_analysis.py | 2 +- tests/python/contrib/test_hexagon/test_run_unit_tests.py | 2 +- tests/python/relax/test_group_gemm_flashinfer.py | 2 +- tests/scripts/release/make_notes.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/tvm/relax/frontend/torch/fx_translator.py b/python/tvm/relax/frontend/torch/fx_translator.py index 74ffebd82362..5fd414d3f409 100644 --- a/python/tvm/relax/frontend/torch/fx_translator.py +++ b/python/tvm/relax/frontend/torch/fx_translator.py @@ -1232,7 +1232,7 @@ def forward(self, input): # Use the dynamo.export() to export the PyTorch model to FX. try: graph_module = dynamo.export(torch_model, *input_tensors) - except: + except Exception: raise RuntimeError("Failed to export the PyTorch model to FX.") # Use the importer to import the PyTorch model to Relax. diff --git a/python/tvm/runtime/_tensor.py b/python/tvm/runtime/_tensor.py index d5810094b511..9eea8a36d2e9 100644 --- a/python/tvm/runtime/_tensor.py +++ b/python/tvm/runtime/_tensor.py @@ -111,7 +111,7 @@ def copyfrom(self, source_array): if not isinstance(source_array, np.ndarray): try: source_array = np.array(source_array, dtype=self.dtype) - except: + except Exception: raise TypeError( f"array must be an array_like data, type {type(source_array)} is not supported" ) diff --git a/python/tvm/s_tir/dlight/analysis/common_analysis.py b/python/tvm/s_tir/dlight/analysis/common_analysis.py index 2ec12b26c0dc..fb44d3fceae8 100644 --- a/python/tvm/s_tir/dlight/analysis/common_analysis.py +++ b/python/tvm/s_tir/dlight/analysis/common_analysis.py @@ -377,7 +377,7 @@ def get_max_shared_memory_per_block(target: Target) -> int: def get_root_block(sch: Schedule, func_name: str = "main") -> SBlockRV: try: block = sch.mod[func_name].body.block - except: + except Exception: raise ValueError( f"The function body is expected to be the root block, but got:\n" f"{sch.mod[func_name].body}" diff --git a/tests/python/contrib/test_hexagon/test_run_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py index 1e82d6a20b77..a7795813cd71 100644 --- a/tests/python/contrib/test_hexagon/test_run_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -151,7 +151,7 @@ def test_run_unit_tests(hexagon_session: Session, gtest_args, unit_test_name): """Try running gtest unit tests and capture output and error code""" try: func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") - except: + except Exception: print( "This test requires TVM Runtime to be built with a Hexagon gtest" "version using Hexagon API cmake flag" diff --git a/tests/python/relax/test_group_gemm_flashinfer.py b/tests/python/relax/test_group_gemm_flashinfer.py index 39ae8d5a30c7..c128fdb35bb5 100644 --- a/tests/python/relax/test_group_gemm_flashinfer.py +++ b/tests/python/relax/test_group_gemm_flashinfer.py @@ -58,7 +58,7 @@ def has_cutlass(): handle = pynvml.nvmlDeviceGetHandleByIndex(0) major, minor = pynvml.nvmlDeviceGetCudaComputeCapability(handle) return major >= 9 # SM90+ - except: + except Exception: return False diff --git a/tests/scripts/release/make_notes.py b/tests/scripts/release/make_notes.py index 82def8adc23c..b599f4b4f305 100644 --- a/tests/scripts/release/make_notes.py +++ b/tests/scripts/release/make_notes.py @@ -218,7 +218,7 @@ def pr_title(number, heading): try: title = pr_dict[int(number)]["title"] title = strip_header(title, heading) - except: + except Exception: sprint("The out.pkl file is not match with csv file.") exit(1) return title