mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-22 18:55:29 +03:00
166 lines
5.2 KiB
Diff
166 lines
5.2 KiB
Diff
From 377d97ce41519e879a6c0111f1193957653a06ae Mon Sep 17 00:00:00 2001
|
|
From: Anton Lazarev <antonok35@gmail.com>
|
|
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(); }
|
|
From 2f049c19200ab4a3a1e4740268450496c12359f9 Mon Sep 17 00:00:00 2001
|
|
From: looooo <sppedflyer@gmail.com>
|
|
Date: Thu, 20 Jan 2022 11:40:08 +0100
|
|
Subject: [PATCH] define PY_SSIZE_T_CLEAN
|
|
|
|
---
|
|
interfaces/coin.i | 4 ++++
|
|
1 file changed, 4 insertions(+)
|
|
|
|
diff --git a/interfaces/coin.i b/interfaces/coin.i
|
|
index 8dc60d2..aec55c6 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 <windows.h>
|