Skip to content

Commit 99dd846

Browse files
suopytorchmergebot
authored andcommitted
[torch] fix builds for older pybind (pytorch#146630)
Summary: some versions of pybind we build with don't have `py::set_error`. So just use the underlying python C API. Test Plan: unit tests Differential Revision: D69254629 Pull Request resolved: pytorch#146630 Approved by: https://github.com/colin2328, https://github.com/ngimel
1 parent 3008368 commit 99dd846

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

torch/csrc/jit/python/script_init.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ void initJitScriptBindings(PyObject* module) {
785785
try {
786786
return toPyObject(self.attr(name));
787787
} catch (const ObjectAttributeError& err) {
788-
pybind11::set_error(PyExc_AttributeError, err.what());
788+
PyErr_SetString(PyExc_AttributeError, err.what());
789789
throw py::error_already_set();
790790
}
791791
})
@@ -807,7 +807,7 @@ void initJitScriptBindings(PyObject* module) {
807807
}
808808
return toPyObject(self.attr(name));
809809
} catch (const ObjectAttributeError& err) {
810-
pybind11::set_error(PyExc_AttributeError, err.what());
810+
PyErr_SetString(PyExc_AttributeError, err.what());
811811
throw py::error_already_set();
812812
}
813813
})
@@ -838,7 +838,7 @@ void initJitScriptBindings(PyObject* module) {
838838
auto ivalue = toIValue(std::move(value), type);
839839
self.setattr(name, ivalue);
840840
} catch (const ObjectAttributeError& err) {
841-
pybind11::set_error(PyExc_AttributeError, err.what());
841+
PyErr_SetString(PyExc_AttributeError, err.what());
842842
throw py::error_already_set();
843843
}
844844
})

0 commit comments

Comments
 (0)