swig/swig-Python-define-PY_SSIZE_T_CLEAN.patch
Klaus Kämpf 73917f97e0 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
2022-10-14 12:17:58 +00:00

48 lines
1.4 KiB
Diff

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