diff --git a/swig-Define-PY_SSIZE_T_CLEAN-macro.patch b/swig-Define-PY_SSIZE_T_CLEAN-macro.patch new file mode 100644 index 0000000..cf91135 --- /dev/null +++ b/swig-Define-PY_SSIZE_T_CLEAN-macro.patch @@ -0,0 +1,62 @@ +From abc8e0bb277f7a54ff4ee209845dde910d267819 Mon Sep 17 00:00:00 2001 +From: William S Fulton +Date: Fri, 27 May 2022 18:58:04 +0100 +Subject: [PATCH] Define PY_SSIZE_T_CLEAN macro + +before #include "Python.h" as recommended in Python 3.7 and later. + +Issue #2277 +--- + CHANGES.current | 11 +++++++++++ + Lib/python/embed.i | 2 +- + Lib/python/pyruntime.swg | 2 +- + 3 files changed, 13 insertions(+), 2 deletions(-) + +Index: swig-4.0.2/CHANGES.current +=================================================================== +--- swig-4.0.2.orig/CHANGES.current ++++ swig-4.0.2/CHANGES.current +@@ -7,6 +7,17 @@ the issue number to the end of the URL: + Version 4.0.2 (8 Jun 2020) + ========================== + ++2022-05-27: xypron ++ [Python] #2277 Define PY_SSIZE_T_CLEAN macro before #include "Python.h" as ++ recommended in Python 3.7 and later. ++ ++ To avoid this macro definition, add the following to your interface file so ++ that SWIG_NO_PY_SSIZE_T_CLEAN is defined at the beginning of the C++ wrappers: ++ ++ %begin %{ ++ #define SWIG_NO_PY_SSIZE_T_CLEAN ++ %} ++ + 2020-06-07 vigsterkr + [Ruby] #1717 Nil fix mangling strings + +Index: swig-4.0.2/Lib/python/embed.i +=================================================================== +--- swig-4.0.2.orig/Lib/python/embed.i ++++ swig-4.0.2/Lib/python/embed.i +@@ -29,7 +29,7 @@ As far as I know, this module is C++ saf + #endif + + %wrapper %{ +-#ifndef PY_SSIZE_T_CLEAN ++#ifndef SWIG_NO_PY_SSIZE_T_CLEAN + #define PY_SSIZE_T_CLEAN + #endif + #include +Index: swig-4.0.2/Lib/python/pyruntime.swg +=================================================================== +--- swig-4.0.2.orig/Lib/python/pyruntime.swg ++++ swig-4.0.2/Lib/python/pyruntime.swg +@@ -4,7 +4,7 @@ + # include + #endif + +-#ifndef PY_SSIZE_T_CLEAN ++#ifndef SWIG_NO_PY_SSIZE_T_CLEAN + #define PY_SSIZE_T_CLEAN + #endif + #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) diff --git a/swig-Define-PY_SSIZE_T_CLEAN-only-when-not-defined-yet.patch b/swig-Define-PY_SSIZE_T_CLEAN-only-when-not-defined-yet.patch new file mode 100644 index 0000000..5709738 --- /dev/null +++ b/swig-Define-PY_SSIZE_T_CLEAN-only-when-not-defined-yet.patch @@ -0,0 +1,44 @@ +From c3f17b415dc63906218306135da49bf1f941588f Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Thu, 13 Oct 2022 23:25:52 +0200 +Subject: [PATCH] Define PY_SSIZE_T_CLEAN only when not defined yet + +Users of swig 4.0.2 and python 3.10 will likely define the +PY_SSIZE_T_CLEAN macro by hand when relevant because their bindings +won't build otherwise. + +Unconditionally defining PY_SSIZE_T_CLEAN in swig 4.10 will lead to +macro redefinition warning. + +Signed-off-by: Michal Suchanek +--- + Lib/python/embed.i | 2 +- + Lib/python/pyruntime.swg | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: swig-4.0.2/Lib/python/embed.i +=================================================================== +--- swig-4.0.2.orig/Lib/python/embed.i ++++ swig-4.0.2/Lib/python/embed.i +@@ -29,7 +29,7 @@ As far as I know, this module is C++ saf + #endif + + %wrapper %{ +-#ifndef SWIG_NO_PY_SSIZE_T_CLEAN ++#if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN) + #define PY_SSIZE_T_CLEAN + #endif + #include +Index: swig-4.0.2/Lib/python/pyruntime.swg +=================================================================== +--- swig-4.0.2.orig/Lib/python/pyruntime.swg ++++ swig-4.0.2/Lib/python/pyruntime.swg +@@ -4,7 +4,7 @@ + # include + #endif + +-#ifndef SWIG_NO_PY_SSIZE_T_CLEAN ++#if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN) + #define PY_SSIZE_T_CLEAN + #endif + #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) diff --git a/swig-Python-define-PY_SSIZE_T_CLEAN.patch b/swig-Python-define-PY_SSIZE_T_CLEAN.patch new file mode 100644 index 0000000..2579283 --- /dev/null +++ b/swig-Python-define-PY_SSIZE_T_CLEAN.patch @@ -0,0 +1,47 @@ +From ca6a73277b7f48ce4cf9d30d7bff7813f3685684 Mon Sep 17 00:00:00 2001 +From: Heinrich Schuchardt +Date: Mon, 9 May 2022 19:53:20 +0200 +Subject: [PATCH] Python: define PY_SSIZE_T_CLEAN + +It is recommended to always define PY_SSIZE_T_CLEAN before including +Python.h. Cf. https://docs.python.org/3/c-api/intro.html + +This avoids errors like: + + SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats + +Signed-off-by: Heinrich Schuchardt +--- + Lib/python/embed.i | 4 +++- + Lib/python/pyruntime.swg | 3 +++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +Index: swig-4.0.2/Lib/python/embed.i +=================================================================== +--- swig-4.0.2.orig/Lib/python/embed.i ++++ swig-4.0.2/Lib/python/embed.i +@@ -29,7 +29,9 @@ As far as I know, this module is C++ saf + #endif + + %wrapper %{ +- ++#ifndef PY_SSIZE_T_CLEAN ++#define PY_SSIZE_T_CLEAN ++#endif + #include + + #ifdef __cplusplus +Index: swig-4.0.2/Lib/python/pyruntime.swg +=================================================================== +--- swig-4.0.2.orig/Lib/python/pyruntime.swg ++++ swig-4.0.2/Lib/python/pyruntime.swg +@@ -4,6 +4,9 @@ + # include + #endif + ++#ifndef PY_SSIZE_T_CLEAN ++#define PY_SSIZE_T_CLEAN ++#endif + #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) + /* Use debug wrappers with the Python release dll */ + # undef _DEBUG diff --git a/swig.changes b/swig.changes index 9c50969..cc62787 100644 --- a/swig.changes +++ b/swig.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Oct 13 17:47:25 UTC 2022 - Michal Suchanek + +- Fix SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats + with python 3.10 gh#swig/swig#2277 + + swig-Python-define-PY_SSIZE_T_CLEAN.patch + + swig-Define-PY_SSIZE_T_CLEAN-macro.patch + + swig-Define-PY_SSIZE_T_CLEAN-only-when-not-defined-yet.patch + ------------------------------------------------------------------- Thu Sep 8 13:23:05 UTC 2022 - Stephan Kulow diff --git a/swig.spec b/swig.spec index 2a2f18f..8b17001 100644 --- a/swig.spec +++ b/swig.spec @@ -47,6 +47,12 @@ Patch2: swig-python310.patch # PATCH-FIX-UPSTREAM 15515f390c5e3316a7faf0cf85d661a297d45a50.patch - gh#swig/swig#2138, remove obsolete pcre1 # from https://github.com/swig/swig/commit/15515f390c5e3316a7faf0cf85d661a297d45a50.patch Patch3: 15515f390c5e3316a7faf0cf85d661a297d45a50.patch +# PATCH-FIX-UPSTREAM https://github.com/swig/swig/pull/2277 +Patch4: swig-Python-define-PY_SSIZE_T_CLEAN.patch +# PATCH-FIX-UPSTREAM https://github.com/swig/swig/pull/2277 +Patch5: swig-Define-PY_SSIZE_T_CLEAN-macro.patch +# PATCH-FIX-UPSTREAM https://github.com/swig/swig/pull/2401 +Patch6: swig-Define-PY_SSIZE_T_CLEAN-only-when-not-defined-yet.patch Patch308: swig308-isfinite.diff BuildRequires: autoconf