Accepting request 1010633 from home:michals

- 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

OBS-URL: https://build.opensuse.org/request/show/1010633
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/swig?expand=0&rev=138
This commit is contained in:
Klaus Kämpf 2022-10-14 12:17:58 +00:00 committed by Git OBS Bridge
parent 7b9c7bae89
commit 73917f97e0
5 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,62 @@
From abc8e0bb277f7a54ff4ee209845dde910d267819 Mon Sep 17 00:00:00 2001
From: William S Fulton <wsf@fultondesigns.co.uk>
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 <Python.h>
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 <math.h>
#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)

View File

@ -0,0 +1,44 @@
From c3f17b415dc63906218306135da49bf1f941588f Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
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 <msuchanek@suse.de>
---
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 <Python.h>
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 <math.h>
#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)

View File

@ -0,0 +1,47 @@
From ca6a73277b7f48ce4cf9d30d7bff7813f3685684 Mon Sep 17 00:00:00 2001
From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
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 <heinrich.schuchardt@canonical.com>
---
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 <Python.h>
#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 <math.h>
#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

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Thu Oct 13 17:47:25 UTC 2022 - Michal Suchanek <msuchanek@suse.com>
- 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 <coolo@suse.com>

View File

@ -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