diff -Nru pivy-0.6.5/debian/changelog pivy-0.6.5/debian/changelog --- pivy-0.6.5/debian/changelog 2022-03-16 18:50:19.000000000 -0400 +++ pivy-0.6.5/debian/changelog 2023-01-02 19:51:20.000000000 -0500 @@ -1,3 +1,9 @@ +pivy (0.6.5-1ubuntu1) jammy; urgency=medium + + * Fix exception in pivy cast functions with Python 3.10 (LP: 2000840) + + -- David Ward Mon, 02 Jan 2023 19:51:20 -0500 + pivy (0.6.5-1build6) jammy; urgency=medium * No-change rebuild with Python 3.10 only diff -Nru pivy-0.6.5/debian/patches/0001-define-PY_SSIZE_T_CLEAN-for-Coin.patch pivy-0.6.5/debian/patches/0001-define-PY_SSIZE_T_CLEAN-for-Coin.patch --- pivy-0.6.5/debian/patches/0001-define-PY_SSIZE_T_CLEAN-for-Coin.patch 1969-12-31 19:00:00.000000000 -0500 +++ pivy-0.6.5/debian/patches/0001-define-PY_SSIZE_T_CLEAN-for-Coin.patch 2023-01-02 19:51:20.000000000 -0500 @@ -0,0 +1,31 @@ +From: David Ward +Date: Thu, 20 Jan 2022 11:40:08 +0100 +Subject: Define PY_SSIZE_T_CLEAN for Coin module + +Author: Lorenz Lechner +Origin: upstream, https://github.com/coin3d/pivy/commit/2f049c19200a +Bug: https://github.com/coin3d/pivy/pull/90 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/pivy/+bug/2000840 +Last-Update: 2023-01-02 + +Since Python 3.10, PY_SSIZE_T_CLEAN must be defined to call PyArg_ParseTuple() +with formats that include '#'. Add this definition for the Coin module. +--- + interfaces/coin.i | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/interfaces/coin.i b/interfaces/coin.i +index c4ba7b9..c0993bd 100644 +--- a/interfaces/coin.i ++++ b/interfaces/coin.i +@@ -28,6 +28,10 @@ applications." + // https://stackoverflow.com/questions/40959436/swig-python-detected-a-memory-leak-of-type-uint32-t-no-destructor-found + %include "stdint.i" + ++%begin %{ ++#define PY_SSIZE_T_CLEAN ++%} ++ + %{ + #if defined(_WIN32) || defined(__WIN32__) + #include diff -Nru pivy-0.6.5/debian/patches/0002-fix-autocast-exception.patch pivy-0.6.5/debian/patches/0002-fix-autocast-exception.patch --- pivy-0.6.5/debian/patches/0002-fix-autocast-exception.patch 1969-12-31 19:00:00.000000000 -0500 +++ pivy-0.6.5/debian/patches/0002-fix-autocast-exception.patch 2023-01-02 19:51:20.000000000 -0500 @@ -0,0 +1,149 @@ +From: David Ward +Date: Mon, 24 Jan 2022 18:57:12 -0800 +Subject: Fix exception in autocast_* functions + +Author: Anton Lazarev +Origin: upstream, https://github.com/coin3d/pivy/commit/4b919a3f6b9f +Bug: https://github.com/coin3d/pivy/pull/91 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/pivy/+bug/2000840 +Last-Update: 2023-01-02 + +PyArg_ParseTuple() is only used to parse a tuple object that has been passed +from Python. Avoid calling it from internal C functions. +--- + 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 -Nru pivy-0.6.5/debian/patches/0003-define-PY_SSIZE_T_CLEAN-for-SoQT-and-fix-argument-type.patch pivy-0.6.5/debian/patches/0003-define-PY_SSIZE_T_CLEAN-for-SoQT-and-fix-argument-type.patch --- pivy-0.6.5/debian/patches/0003-define-PY_SSIZE_T_CLEAN-for-SoQT-and-fix-argument-type.patch 1969-12-31 19:00:00.000000000 -0500 +++ pivy-0.6.5/debian/patches/0003-define-PY_SSIZE_T_CLEAN-for-SoQT-and-fix-argument-type.patch 2023-01-02 19:51:20.000000000 -0500 @@ -0,0 +1,54 @@ +From: David Ward +Date: Tue, 23 Aug 2022 17:47:40 -0300 +Subject: Define PY_SSIZE_T_CLEAN for SoQT module, and fix argument type + +Author: Mario Passaglia +Origin: upstream, https://github.com/coin3d/pivy/commit/fce09ce8f4f2 +Bug: https://github.com/coin3d/pivy/pull/99 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/pivy/+bug/2000840 +Last-Update: 2023-01-02 + +Since Python 3.10, PY_SSIZE_T_CLEAN must be defined to call PyArg_ParseTuple() +with formats that include '#'. Add this definition for the SoQT module. Also, +fix the type of the corresponding argument to PyArg_ParseTuple(). +--- + interfaces/pivy_common_typemaps.i | 4 ++-- + interfaces/soqt.i | 3 +++ + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/interfaces/pivy_common_typemaps.i b/interfaces/pivy_common_typemaps.i +index 27e26a6..4933b85 100644 +--- a/interfaces/pivy_common_typemaps.i ++++ b/interfaces/pivy_common_typemaps.i +@@ -29,7 +29,7 @@ typedef int Py_ssize_t; + #endif + + PyObject * +-cast_internal(PyObject * self, PyObject * obj, const char * type_name, int type_len) ++cast_internal(PyObject * self, PyObject * obj, const char * type_name, Py_ssize_t type_len) + { + swig_type_info * swig_type = 0; + void * cast_obj = 0; +@@ -76,7 +76,7 @@ SWIGEXPORT PyObject * + cast(PyObject * self, PyObject * args) + { + char * type_name; +- int type_len; ++ Py_ssize_t type_len; + PyObject * obj = 0; + + if (!PyArg_ParseTuple(args, "Os#:cast", &obj, &type_name, &type_len)) { +diff --git a/interfaces/soqt.i b/interfaces/soqt.i +index 156420d..690e6e2 100644 +--- a/interfaces/soqt.i ++++ b/interfaces/soqt.i +@@ -23,6 +23,9 @@ otherwise it will fall back to regular SWIG structures." + + %module(package="pivy.gui", docstring=SOQT_MODULE_DOCSTRING) soqt + ++%begin %{ ++#define PY_SSIZE_T_CLEAN ++%} + + %{ + /* diff -Nru pivy-0.6.5/debian/patches/series pivy-0.6.5/debian/patches/series --- pivy-0.6.5/debian/patches/series 1969-12-31 19:00:00.000000000 -0500 +++ pivy-0.6.5/debian/patches/series 2023-01-02 19:51:20.000000000 -0500 @@ -0,0 +1,3 @@ +0001-define-PY_SSIZE_T_CLEAN-for-Coin.patch +0002-fix-autocast-exception.patch +0003-define-PY_SSIZE_T_CLEAN-for-SoQT-and-fix-argument-type.patch