Browse Source

python: update docs about working around a pybind11 misbehavior.

It was specific to Python 3.7, which is already EOL'd, so not much point
in investigating further. I won't deliberately make it broken there
though, so the order will stay maintained like this as much as possible.
next
Vladimír Vondruš 3 years ago
parent
commit
2696ac6ba7
  1. 20
      src/python/magnum/trade.cpp

20
src/python/magnum/trade.cpp

@ -898,11 +898,11 @@ void trade(py::module_& m) {
.def("has_attribute", &Trade::MeshData::hasAttribute, "Whether the mesh has given attribute", py::arg("name")) .def("has_attribute", &Trade::MeshData::hasAttribute, "Whether the mesh has given attribute", py::arg("name"))
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Trade::MeshAttribute) const>(&Trade::MeshData::attributeCount), "Count of given named attribute", py::arg("name")) .def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Trade::MeshAttribute) const>(&Trade::MeshData::attributeCount), "Count of given named attribute", py::arg("name"))
/* IMPORTANT: due to yet-uninvestigated pybind11 platform-specific /* IMPORTANT: due to pybind11 behavioral differences on (already EOL'd)
behavioral differences the following overloads need to have the Python 3.7 the following overloads need to have the MeshAttribute
MeshAttribute overload *before* the UnsignedInt overload, otherwise overload *before* the UnsignedInt overload, otherwise the integer
the integer overload gets picked even if an enum is passed from overload gets picked even if an enum is passed from Python, causing
Python, causing massive suffering */ massive suffering */
.def("attribute_name", [](Trade::MeshData& self, UnsignedInt id) { .def("attribute_name", [](Trade::MeshData& self, UnsignedInt id) {
if(id >= self.attributeCount()) { if(id >= self.attributeCount()) {
PyErr_SetNone(PyExc_IndexError); PyErr_SetNone(PyExc_IndexError);
@ -1194,11 +1194,11 @@ void trade(py::module_& m) {
.def_property_readonly("is_2d", &Trade::SceneData::is2D, "Whether the scene is two-dimensional") .def_property_readonly("is_2d", &Trade::SceneData::is2D, "Whether the scene is two-dimensional")
.def_property_readonly("is_3d", &Trade::SceneData::is3D, "Whether the scene is three-dimensional") .def_property_readonly("is_3d", &Trade::SceneData::is3D, "Whether the scene is three-dimensional")
/* IMPORTANT: due to yet-uninvestigated pybind11 platform-specific /* IMPORTANT: due to pybind11 behavioral differences on (already EOL'd)
behavioral differences the following overloads need to have the Python 3.7 the following overloads need to have the SceneField
SceneField overload *before* the UnsignedInt overload, otherwise overload *before* the UnsignedInt overload, otherwise the integer
the integer overload gets picked even if an enum is passed from overload gets picked even if an enum is passed from Python, causing
Python, causing massive suffering */ massive suffering */
.def("field_name", [](Trade::SceneData& self, UnsignedInt id) { .def("field_name", [](Trade::SceneData& self, UnsignedInt id) {
if(id >= self.fieldCount()) { if(id >= self.fieldCount()) {
PyErr_SetNone(PyExc_IndexError); PyErr_SetNone(PyExc_IndexError);

Loading…
Cancel
Save