[Exception] [6/N] Remove use of torch::TypeError (#117964)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/117964
Approved by: https://github.com/albanD
This commit is contained in:
cyy
2024-01-25 03:35:53 +00:00
committed by PyTorch MergeBot
parent 67300a11cb
commit 87335fabae
12 changed files with 191 additions and 170 deletions

View File

@ -209,8 +209,8 @@ PyObject* THPModule_disable_torch_function(PyObject* self, PyObject* a) {
} else if (PyTuple_Check(args)) {
py_args = py::reinterpret_borrow<py::tuple>(args);
} else {
throw torch::TypeError(
"expected List or Tuple (got %s)", Py_TYPE(args)->tp_name);
TORCH_CHECK_TYPE(
false, "expected List or Tuple (got ", Py_TYPE(args)->tp_name, ")");
}
// These are all C-API calls so no exceptions will be raised
@ -243,8 +243,8 @@ PyObject* THPModule_disable_torch_dispatch(PyObject* self, PyObject* a) {
} else if (PyTuple_Check(args)) {
py_args = py::reinterpret_borrow<py::tuple>(args);
} else {
throw torch::TypeError(
"expected List or Tuple (got %s)", Py_TYPE(args)->tp_name);
TORCH_CHECK_TYPE(
false, "expected List or Tuple (got ", Py_TYPE(args)->tp_name, ")");
}
// This implementation is not completely correct. The moral