Skip to content

Commit ca6a732

Browse files
committed
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 <[email protected]>
1 parent 6939d91 commit ca6a732

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/python/embed.i

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

3131
%wrapper %{
32-
32+
#ifndef PY_SSIZE_T_CLEAN
33+
#define PY_SSIZE_T_CLEAN
34+
#endif
3335
#include <Python.h>
3436

3537
#ifdef __cplusplus

Lib/python/pyruntime.swg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
# include <corecrt.h>
1212
#endif
1313

14+
#ifndef PY_SSIZE_T_CLEAN
15+
#define PY_SSIZE_T_CLEAN
16+
#endif
1417
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
1518
/* Use debug wrappers with the Python release dll */
1619
# undef _DEBUG

0 commit comments

Comments
 (0)