Skip to content

Commit abc8e0b

Browse files
committed
Define PY_SSIZE_T_CLEAN macro
before #include "Python.h" as recommended in Python 3.7 and later. Issue swig#2277
1 parent ca6a732 commit abc8e0b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGES.current

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
77
Version 4.1.0 (in progress)
88
===========================
99

10+
2022-05-27: xypron
11+
[Python] #2277 Define PY_SSIZE_T_CLEAN macro before #include "Python.h" as
12+
recommended in Python 3.7 and later.
13+
14+
To avoid this macro definition, add the following to your interface file so
15+
that SWIG_NO_PY_SSIZE_T_CLEAN is defined at the beginning of the C++ wrappers:
16+
17+
%begin %{
18+
#define SWIG_NO_PY_SSIZE_T_CLEAN
19+
%}
20+
1021
2022-05-07: KrisThielemans
1122
[Python] Fix "too many initializers for 'PyHeapTypeObject'" errors
1223
using PyPy 3.8 and later.

Lib/python/embed.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ As far as I know, this module is C++ safe.
2929
#endif
3030

3131
%wrapper %{
32-
#ifndef PY_SSIZE_T_CLEAN
32+
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
3333
#define PY_SSIZE_T_CLEAN
3434
#endif
3535
#include <Python.h>

Lib/python/pyruntime.swg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# include <corecrt.h>
1212
#endif
1313

14-
#ifndef PY_SSIZE_T_CLEAN
14+
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
1515
#define PY_SSIZE_T_CLEAN
1616
#endif
1717
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)

0 commit comments

Comments
 (0)