diff mbox series

[meta-networking,4/4] openipmi: add SWIG py2/py3 C-API compat patch for python bindings

Message ID 20260814003819.1417656-4-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,1/4] python3-fann2: add SWIG py2/py3 C-API compat patch | expand

Commit Message

Khem Raj Aug. 14, 2026, 12:38 a.m. UTC
The Python-language SWIG typemaps in OpenIPMI_lang.i use the Python 2
C-API names PyInt_Check/PyInt_AsLong/PyInt_FromLong/PyString_FromString(AndSize).
Python 3.14 no longer ships any fallback definitions for them, so the
generated OpenIPMI_wrap.c fails to compile:

  OpenIPMI_wrap.c:13486:10: error: use of undeclared identifier 'PyInt_Check'
  OpenIPMI_wrap.c:14950:21: error: use of undeclared identifier 'PyString_FromString'; did you mean 'PyLong_FromString'?

Add a patch mapping them to their Python 3 equivalents.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...nIPMI_lang.i-add-py2-py3-C-API-compa.patch | 43 +++++++++++++++++++
 .../openipmi/openipmi_2.0.37.bb               |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta-networking/recipes-support/openipmi/files/0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch
diff mbox series

Patch

diff --git a/meta-networking/recipes-support/openipmi/files/0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch b/meta-networking/recipes-support/openipmi/files/0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch
new file mode 100644
index 0000000000..5f9f892228
--- /dev/null
+++ b/meta-networking/recipes-support/openipmi/files/0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch
@@ -0,0 +1,43 @@ 
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Subject: swig/python/OpenIPMI_lang.i: add py2/py3 C-API compat macros
+
+The Python-language SWIG typemaps use the Python 2 C-API names
+PyInt_Check/PyInt_AsLong/PyInt_FromLong/PyString_FromString(AndSize).
+Python 3.14 no longer ships any fallback definitions for them, so the
+generated OpenIPMI_wrap.c fails to compile:
+
+  OpenIPMI_wrap.c:13486:10: error: use of undeclared identifier 'PyInt_Check'
+  OpenIPMI_wrap.c:14950:21: error: use of undeclared identifier 'PyString_FromString'; did you mean 'PyLong_FromString'?
+
+Map them to their Python 3 equivalents.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+--- a/swig/python/OpenIPMI_lang.i
++++ b/swig/python/OpenIPMI_lang.i
+@@ -31,6 +31,24 @@
+  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+  */
+
++%{
++#ifndef PyInt_Check
++#define PyInt_Check(x) PyLong_Check(x)
++#endif
++#ifndef PyInt_AsLong
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#endif
++#ifndef PyInt_FromLong
++#define PyInt_FromLong(x) PyLong_FromLong(x)
++#endif
++#ifndef PyString_FromString
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#endif
++#ifndef PyString_FromStringAndSize
++#define PyString_FromStringAndSize(x, n) PyUnicode_FromStringAndSize(x, n)
++#endif
++%}
++
+ %typemap(in) swig_cb * {
+     if ($input == Py_None)
+ 	$1 = NULL;
diff --git a/meta-networking/recipes-support/openipmi/openipmi_2.0.37.bb b/meta-networking/recipes-support/openipmi/openipmi_2.0.37.bb
index c945428307..9409a67d4b 100644
--- a/meta-networking/recipes-support/openipmi/openipmi_2.0.37.bb
+++ b/meta-networking/recipes-support/openipmi/openipmi_2.0.37.bb
@@ -29,6 +29,7 @@  SRC_URI = "${SOURCEFORGE_MIRROR}/openipmi/OpenIPMI-${PV}.tar.gz \
            file://ipmi-init-fix-the-arguments.patch \
            file://include_sys_types.patch \
            file://0001-Makefile.am-Pass-BUILD_CFLAGS-to-BUILD_CC.patch \
+           file://0002-swig-python-OpenIPMI_lang.i-add-py2-py3-C-API-compa.patch \
            file://openipmi-helper \
            file://ipmi.service \
            "