Define PY_SSIZE_T_CLEAN macro

before #include "Python.h" as recommended in Python 3.7 and later.

Issue #2277
This commit is contained in:
William S Fulton 2022-05-27 18:58:04 +01:00
commit abc8e0bb27
3 changed files with 13 additions and 2 deletions

View file

@ -7,6 +7,17 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
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
%}
2022-05-07: KrisThielemans
[Python] Fix "too many initializers for 'PyHeapTypeObject'" errors
using PyPy 3.8 and later.

View file

@ -29,7 +29,7 @@ As far as I know, this module is C++ safe.
#endif
%wrapper %{
#ifndef PY_SSIZE_T_CLEAN
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif
#include <Python.h>

View file

@ -11,7 +11,7 @@
# include <corecrt.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)