From 629cca9413804631bad528c10d3632499cbc9a71 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 5 Nov 2024 10:46:08 +0100 Subject: [PATCH] Use std::tuple instead of py::tuple with length and type checks --- libsrc/occ/python_occ_basic.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libsrc/occ/python_occ_basic.cpp b/libsrc/occ/python_occ_basic.cpp index cff6131f..bf5cd64e 100644 --- a/libsrc/occ/python_occ_basic.cpp +++ b/libsrc/occ/python_occ_basic.cpp @@ -167,12 +167,9 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m) py::class_(m, "gp_Pnt2d", "2d OCC point") - .def(py::init([] (py::tuple pnt) + .def(py::init([] (std::tuple pnt) { - if (py::len(pnt) != 2) - throw std::invalid_argument("need 2-tuple to create gp_Pnt2d"); - return gp_Pnt2d(py::cast(pnt[0]), - py::cast(pnt[1])); + return gp_Pnt2d(get<0>(pnt), get<1>(pnt)); })) .def(py::init([] (double x, double y) { return gp_Pnt2d(x, y);