Commit af40e0b
Martin Belanger
swig: fix Py_NewRef compatibility with Python < 3.10
SWIG >= 4.1 generates calls to Py_NewRef() in its runtime boilerplate.
Py_NewRef was introduced in Python 3.10, causing an undefined symbol
error on older distributions (e.g. SLES 15.6/15.7 with Python 3.6).
The shim must live in a %begin block so it precedes SWIG's own runtime
in the generated C file. Since Python.h is not yet included at that
point, PyObject is unavailable, so a macro is used instead of an inline
function. A -DSWIG_COMPAT_PY_NEWREF flag, set by meson when Py_NewRef
is absent, gates the macro so it never conflicts with Python 3.10+'s own
definition.
Signed-off-by: Martin Belanger <[email protected]>
Assisted-by: Claude Sonnet 4.6 <[email protected]>1 parent f018b37 commit af40e0b
2 files changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| |||
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
| |||
0 commit comments