Skip to content

Commit adaef97

Browse files
fix: replace bare except clauses with except Exception
Bare `except:` catches BaseException including KeyboardInterrupt and SystemExit. Replaced 6 instances with `except Exception:`.
1 parent f8dc0fb commit adaef97

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

python/tvm/relax/frontend/torch/fx_translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ def forward(self, input):
12321232
# Use the dynamo.export() to export the PyTorch model to FX.
12331233
try:
12341234
graph_module = dynamo.export(torch_model, *input_tensors)
1235-
except:
1235+
except Exception:
12361236
raise RuntimeError("Failed to export the PyTorch model to FX.")
12371237
12381238
# Use the importer to import the PyTorch model to Relax.

python/tvm/runtime/_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def copyfrom(self, source_array):
111111
if not isinstance(source_array, np.ndarray):
112112
try:
113113
source_array = np.array(source_array, dtype=self.dtype)
114-
except:
114+
except Exception:
115115
raise TypeError(
116116
f"array must be an array_like data, type {type(source_array)} is not supported"
117117
)

python/tvm/s_tir/dlight/analysis/common_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def get_max_shared_memory_per_block(target: Target) -> int:
377377
def get_root_block(sch: Schedule, func_name: str = "main") -> SBlockRV:
378378
try:
379379
block = sch.mod[func_name].body.block
380-
except:
380+
except Exception:
381381
raise ValueError(
382382
f"The function body is expected to be the root block, but got:\n"
383383
f"{sch.mod[func_name].body}"

tests/python/contrib/test_hexagon/test_run_unit_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_run_unit_tests(hexagon_session: Session, gtest_args, unit_test_name):
151151
"""Try running gtest unit tests and capture output and error code"""
152152
try:
153153
func = hexagon_session._rpc.get_function("hexagon.run_unit_tests")
154-
except:
154+
except Exception:
155155
print(
156156
"This test requires TVM Runtime to be built with a Hexagon gtest"
157157
"version using Hexagon API cmake flag"

tests/python/relax/test_group_gemm_flashinfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def has_cutlass():
5858
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
5959
major, minor = pynvml.nvmlDeviceGetCudaComputeCapability(handle)
6060
return major >= 9 # SM90+
61-
except:
61+
except Exception:
6262
return False
6363

6464

tests/scripts/release/make_notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def pr_title(number, heading):
218218
try:
219219
title = pr_dict[int(number)]["title"]
220220
title = strip_header(title, heading)
221-
except:
221+
except Exception:
222222
sprint("The out.pkl file is not match with csv file.")
223223
exit(1)
224224
return title

0 commit comments

Comments
 (0)