From 8f97045d51cb9e48294a1ec4b4a137333000c1ab Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sat, 16 Apr 2022 14:30:17 -0400 Subject: [PATCH] python3-pivy: fix for Python 3.10 backports coin3d/pivy#91 --- srcpkgs/python3-pivy/patches/python3.10.patch | 143 ++++++++++++++++++ srcpkgs/python3-pivy/template | 2 +- 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/python3-pivy/patches/python3.10.patch diff --git a/srcpkgs/python3-pivy/patches/python3.10.patch b/srcpkgs/python3-pivy/patches/python3.10.patch new file mode 100644 index 000000000000..34c533bf5130 --- /dev/null +++ b/srcpkgs/python3-pivy/patches/python3.10.patch @@ -0,0 +1,143 @@ +From 377d97ce41519e879a6c0111f1193957653a06ae Mon Sep 17 00:00:00 2001 +From: Anton Lazarev +Date: Mon, 24 Jan 2022 18:57:12 -0800 +Subject: [PATCH] tests no longer segfault on Python 3.10 + +--- + interfaces/pivy_common_typemaps.i | 52 +++++++++++++++---------------- + 1 file changed, 25 insertions(+), 27 deletions(-) + +diff --git a/interfaces/pivy_common_typemaps.i b/interfaces/pivy_common_typemaps.i +index 13f9a8c..27e26a6 100644 +--- a/interfaces/pivy_common_typemaps.i ++++ b/interfaces/pivy_common_typemaps.i +@@ -28,19 +28,12 @@ typedef int Py_ssize_t; + #define IS_PY3K + #endif + +-/* a casting helper function */ +-SWIGEXPORT PyObject * +-cast(PyObject * self, PyObject * args) ++PyObject * ++cast_internal(PyObject * self, PyObject * obj, const char * type_name, int type_len) + { + swig_type_info * swig_type = 0; + void * cast_obj = 0; +- char * type_name, * ptr_type; +- int type_len; +- PyObject * obj = 0; +- +- if (!PyArg_ParseTuple(args, "Os#:cast", &obj, &type_name, &type_len)) { +- SWIG_fail; +- } ++ char * ptr_type; + + /* + * add a pointer sign to the string coming from the interpreter +@@ -74,7 +67,24 @@ cast(PyObject * self, PyObject * args) + if (SWIG_arg_fail(1)) { SWIG_fail; } + + return SWIG_NewPointerObj((void*)cast_obj, swig_type, 0); +- fail: ++fail: ++ return NULL; ++} ++ ++/* a casting helper function */ ++SWIGEXPORT PyObject * ++cast(PyObject * self, PyObject * args) ++{ ++ char * type_name; ++ int type_len; ++ PyObject * obj = 0; ++ ++ if (!PyArg_ParseTuple(args, "Os#:cast", &obj, &type_name, &type_len)) { ++ SWIG_fail; ++ } ++ ++ return cast_internal(self, obj, type_name, type_len); ++fail: + return NULL; + } + +@@ -86,18 +96,15 @@ autocast_base(SoBase * base) + + /* autocast the result to the corresponding type */ + if (base && base->isOfType(SoFieldContainer::getClassTypeId())) { +- PyObject * cast_args = NULL; + PyObject * obj = NULL; + SoType type = base->getTypeId(); + + /* in case of a non built-in type get the closest built-in parent */ + while (!(type.isBad() || result)) { + obj = SWIG_NewPointerObj((void*)base, SWIGTYPE_p_SoBase, 0); +- cast_args = Py_BuildValue("(Os)", obj, type.getName().getString()); + +- result = cast(NULL, cast_args); ++ result = cast_internal(NULL, obj, type.getName().getString(), type.getName().getLength()); + +- Py_DECREF(cast_args); + Py_DECREF(obj); + + if (!result) { type = type.getParent(); } +@@ -120,18 +127,15 @@ autocast_path(SoPath * path) + + /* autocast the result to the corresponding type */ + if (path) { +- PyObject * cast_args = NULL; + PyObject * obj = NULL; + SoType type = path->getTypeId(); + + /* in case of a non built-in type get the closest built-in parent */ + while (!(type.isBad() || result)) { + obj = SWIG_NewPointerObj((void*)path, SWIGTYPE_p_SoPath, 0); +- cast_args = Py_BuildValue("(Os)", obj, type.getName().getString()); + +- result = cast(NULL, cast_args); ++ result = cast_internal(NULL, obj, type.getName().getString(), type.getName().getLength()); + +- Py_DECREF(cast_args); + Py_DECREF(obj); + + if (!result) { type = type.getParent(); } +@@ -154,18 +158,15 @@ autocast_field(SoField * field) + + /* autocast the result to the corresponding type */ + if (field) { +- PyObject * cast_args = NULL; + PyObject * obj = NULL; + SoType type = field->getTypeId(); + + /* in case of a non built-in type get the closest built-in parent */ + while (!(type.isBad() || result)) { + obj = SWIG_NewPointerObj((void*)field, SWIGTYPE_p_SoField, 0); +- cast_args = Py_BuildValue("(Os)", obj, type.getName().getString()); + +- result = cast(NULL, cast_args); ++ result = cast_internal(NULL, obj, type.getName().getString(), type.getName().getLength()); + +- Py_DECREF(cast_args); + Py_DECREF(obj); + + if (!result) { type = type.getParent(); } +@@ -188,18 +189,15 @@ autocast_event(SoEvent * event) + + /* autocast the result to the corresponding type */ + if (event) { +- PyObject * cast_args = NULL; + PyObject * obj = NULL; + SoType type = event->getTypeId(); + + /* in case of a non built-in type get the closest built-in parent */ + while (!(type.isBad() || result)) { + obj = SWIG_NewPointerObj((void*)event, SWIGTYPE_p_SoEvent, 0); +- cast_args = Py_BuildValue("(Os)", obj, type.getName().getString()); + +- result = cast(NULL, cast_args); ++ result = cast_internal(NULL, obj, type.getName().getString(), type.getName().getLength()); + +- Py_DECREF(cast_args); + Py_DECREF(obj); + + if (!result) { type = type.getParent(); } + diff --git a/srcpkgs/python3-pivy/template b/srcpkgs/python3-pivy/template index 6105058d9982..794e03bc8c41 100644 --- a/srcpkgs/python3-pivy/template +++ b/srcpkgs/python3-pivy/template @@ -1,7 +1,7 @@ # Template file for 'python3-pivy' pkgname=python3-pivy version=0.6.6 -revision=3 +revision=4 wrksrc="pivy-${version}" build_style=cmake hostmakedepends="python3-devel swig"