From 9c1e4c7add92680c7dc4d89b35b03343f23999be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 9 Feb 2023 02:30:01 +0100 Subject: [PATCH] python: use PyErr_SetNone() if the string is empty. --- src/python/magnum/trade.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/python/magnum/trade.cpp b/src/python/magnum/trade.cpp index 7f46c76..81026f2 100644 --- a/src/python/magnum/trade.cpp +++ b/src/python/magnum/trade.cpp @@ -653,7 +653,7 @@ void trade(py::module_& m) { Python, causing massive suffering */ .def("attribute_name", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeName(id); @@ -661,12 +661,12 @@ void trade(py::module_& m) { .def("attribute_id", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { if(const Containers::Optional found = self.findAttributeId(name, id)) return *found; - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; }, "Absolute ID of a named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute_id", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeId(id); @@ -674,12 +674,12 @@ void trade(py::module_& m) { .def("attribute_format", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { if(const Containers::Optional found = self.findAttributeId(name, id)) return self.attributeFormat(*found); - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; }, "Format of a named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute_format", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeFormat(id); @@ -687,12 +687,12 @@ void trade(py::module_& m) { .def("attribute_offset", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { if(const Containers::Optional found = self.findAttributeId(name, id)) return self.attributeOffset(*found); - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; }, "Offset of a named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute_offset", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeOffset(id); @@ -700,12 +700,12 @@ void trade(py::module_& m) { .def("attribute_stride", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { if(const Containers::Optional found = self.findAttributeId(name, id)) return self.attributeStride(*found); - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; }, "Stride of a named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute_stride", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeStride(id); @@ -713,12 +713,12 @@ void trade(py::module_& m) { .def("attribute_array_size", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { if(const Containers::Optional found = self.findAttributeId(name, id)) return self.attributeArraySize(*found); - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; }, "Array size of a named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute_array_size", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } return self.attributeArraySize(id); @@ -726,7 +726,7 @@ void trade(py::module_& m) { .def("attribute", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { const Containers::Optional found = self.findAttributeId(name, id); if(!found) { - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; } /** @todo handle arrays (return a 2D view, and especially annotate @@ -739,7 +739,7 @@ void trade(py::module_& m) { }, "Data for given named attribute", py::arg("name"), py::arg("id") = 0) .def("attribute", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } /** @todo handle arrays (return a 2D view, and especially annotate @@ -753,7 +753,7 @@ void trade(py::module_& m) { .def("mutable_attribute", [](Trade::MeshData& self, Trade::MeshAttribute name, UnsignedInt id) { const Containers::Optional found = self.findAttributeId(name, id); if(!found) { - PyErr_SetString(PyExc_KeyError, ""); + PyErr_SetNone(PyExc_KeyError); throw py::error_already_set{}; } if(!(self.vertexDataFlags() & Trade::DataFlag::Mutable)) { @@ -770,7 +770,7 @@ void trade(py::module_& m) { }, "Data for given named attribute", py::arg("name"), py::arg("id") = 0) .def("mutable_attribute", [](Trade::MeshData& self, UnsignedInt id) { if(id >= self.attributeCount()) { - PyErr_SetString(PyExc_IndexError, ""); + PyErr_SetNone(PyExc_IndexError); throw py::error_already_set{}; } if(!(self.vertexDataFlags() & Trade::DataFlag::Mutable)) {