public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/dtc] rawhide: Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility
@ 2026-08-08 16:26 Jitka Plesnikova
  0 siblings, 0 replies; only message in thread
From: Jitka Plesnikova @ 2026-08-08 16:26 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/dtc
            Branch : rawhide
            Commit : 1032395d506475ec00e2fada7d6bbbd478b7b3e8
            Author : Jitka Plesnikova <jplesnik@redhat.com>
            Date   : 2026-07-30T13:38:49+02:00
            Stats  : +61/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/dtc/c/1032395d506475ec00e2fada7d6bbbd478b7b3e8?branch=rawhide

            Log:
            Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility

Updated patchto proper format

---
diff --git a/dtc-swig45.patch b/dtc-swig45.patch
new file mode 100644
index 0000000..f6862cc
--- /dev/null
+++ b/dtc-swig45.patch
@@ -0,0 +1,53 @@
+From 015cf4a9f95f0fe65ebec86a0f2d6ddacb8c18d0 Mon Sep 17 00:00:00 2001
+From: Jitka Plesnikova <jplesnik@redhat.com>
+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 <jplesnik@redhat.com>
+---
+ pylibfdt/libfdt.i | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
+index 1f9c047..b1cb987 100644
+--- a/pylibfdt/libfdt.i
++++ b/pylibfdt/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;
+ }
+ 
+-- 
+2.55.0
+

diff --git a/dtc.spec b/dtc.spec
index 9a64a47..54c85e7 100644
--- a/dtc.spec
+++ b/dtc.spec
@@ -8,12 +8,16 @@
 
 Name:          dtc
 Version:       1.8.1
-Release:       4%{?dist}
+Release:       5%{?dist}
 Summary:       Device Tree Compiler
 License:       GPL-2.0-or-later
 URL:           https://devicetree.org/
 Source0:       https://www.kernel.org/pub/software/utils/%{name}/%{name}-%{version}.tar.xz
 
+# Replace removed Python 2 C API macros with Python 3 equivalents
+# for compatibility with SWIG 4.5.0
+Patch0:        dtc-swig45.patch
+
 BuildRequires: gcc
 BuildRequires: meson
 BuildRequires: python3-devel
@@ -180,6 +184,9 @@ This package provides the static library of mingw64-libfdt
 %endif
 
 %changelog
+* Mon Jul 27 2026 Jitka Plesnikova <jplesnik@redhat.com> - 1.8.1-5
+- Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility
+
 * Wed Jul 22 2026 Python Maint <python-maint@redhat.com> - 1.8.1-4
 - Rebuilt for Python 3.15.0b4 ABI change
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-08 16:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-08 16:26 [rpms/dtc] rawhide: Replace removed Python 2 C API macros for SWIG 4.5.0 compatibility Jitka Plesnikova

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox