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