From f70de5ac394e22546410c10ccfe2806a49060ebf Mon Sep 17 00:00:00 2001 From: Bernd Kuhls Date: Sat, 5 Sep 2026 14:20:37 +0200 Subject: [PATCH] package/python-pylibfdt: fix build with swig >= 4.5.0 Signed-off-by: Bernd Kuhls Signed-off-by: Thomas Petazzoni --- ...e-removed-SWIG-Python-2-compatibilit.patch | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 package/python-pylibfdt/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibilit.patch diff --git a/package/python-pylibfdt/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibilit.patch b/package/python-pylibfdt/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibilit.patch new file mode 100644 index 0000000000..fa2b587ddc --- /dev/null +++ b/package/python-pylibfdt/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibilit.patch @@ -0,0 +1,59 @@ +From 5008d1d6a356b8d0a78060da2e1021507d529cff Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova +Date: Wed, 29 Jul 2026 07:55:56 +0200 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova +Signed-off-by: Peter Robinson +Signed-off-by: David Gibson + +Upstream: https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff + +python-pylibfdt imports tagged dtc versions and currently waits for a +new dtc release: https://github.com/devicetree-org/pylibfdt/pull/10 + +Signed-off-by: Bernd Kuhls +--- + libfdt/libfdt.i | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libfdt/libfdt.i b/libfdt/libfdt.i +index 1f9c0471..b1cb9873 100644 +--- a/libfdt/libfdt.i ++++ b/libfdt/libfdt.i +@@ -1136,7 +1136,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1169,13 +1169,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +