Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
To: openembedded-core@lists.openembedded.org
Cc: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
Subject: [PATCH v4 2/4] babeltrace2: fix build with swig 4.5.0
Date: Tue, 11 Aug 2026 15:51:58 +0200	[thread overview]
Message-ID: <20260811135200.18942-3-jaipaul.cheernam@est.tech> (raw)
In-Reply-To: <20260811135200.18942-1-jaipaul.cheernam@est.tech>

SWIG 4.5.0 removed Python 2/3 compatibility macros PyString_FromString
and SWIG_Python_str_FromChar. Backport upstream fix that replaces both
with PyUnicode_FromString.

Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
---
 ...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++
 .../recipes-kernel/lttng/babeltrace2_2.1.2.bb |  1 +
 2 files changed, 71 insertions(+)
 create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch

diff --git a/meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch b/meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
new file mode 100644
index 0000000000..e0b042d62d
--- /dev/null
+++ b/meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
@@ -0,0 +1,70 @@
+From 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3 Mon Sep 17 00:00:00 2001
+From: Jitka Plesnikova <jplesnik@redhat.com>
+Date: Mon, 28 Jul 2026 13:29:18 +0000
+Subject: [PATCH] bt2: replace removed Python 2 C API macros for SWIG 4.5.0
+ compatibility
+
+SWIG 4.5.0 has removed some Python 2/3 compatibility macros.  The two
+that affect us are `PyString_FromString` and
+`SWIG_Python_str_FromChar`, which are both replaced with
+`PyUnicode_FromString`.
+
+Change-Id: I3c74d8ea7257d9cdc0fa4b533ae7b3a5ef9521d1
+Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
+Signed-off-by: Jitka Plesnikova <jplesnik@redhat.com>
+Reviewed-on: https://review.lttng.org/c/babeltrace/+/18423
+Tested-by: jenkins <jenkins@lttng.org>
+(cherry picked from commit 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3)
+
+Upstream-Status: Backport [https://github.com/efficios/babeltrace/commit/1c59884d4d]
+
+Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
+---
+ src/bindings/python/bt2/bt2/native_bt.i           | 4 ++--
+ src/bindings/python/bt2/bt2/native_bt_error.i.hpp | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i
+index 7f8d9f699..1807d8ff6 100644
+--- a/src/bindings/python/bt2/bt2/native_bt.i
++++ b/src/bindings/python/bt2/bt2/native_bt.i
+@@ -56,7 +56,7 @@ typedef uint64_t bt_listener_id;
+  *
+  * We initialize the output parameter `temp_value` to an invalid but non-zero
+  * pointer value.  This is to make sure we don't rely on its initial value in
+- * the epilogue (where we call SWIG_Python_str_FromChar).  When they fail,
++ * the epilogue (where we call PyUnicode_FromString).  When they fail,
+  * functions on which we apply this typemap don't guarantee that the value of
+  * `temp_value` will be unchanged or valid.
+  */
+@@ -67,7 +67,7 @@ typedef uint64_t bt_listener_id;
+ %typemap(argout) (const char **) {
+ 	if (*$1) {
+ 		/* SWIG_AppendOutput() steals the created object */
+-		$result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1));
++		$result = SWIG_AppendOutput($result, PyUnicode_FromString(*$1));
+ 	} else {
+ 		/* SWIG_AppendOutput() steals Py_None */
+ 		Py_INCREF(Py_None);
+diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp
+index ba8cef097..2be1e347c 100644
+--- a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp
++++ b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp
+@@ -19,7 +19,7 @@ static PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause)
+                               BT_COMMON_COLOR_WHEN_NEVER);
+     BT_ASSERT(error_cause_str);
+ 
+-    py_error_cause_str = PyString_FromString(error_cause_str);
++    py_error_cause_str = PyUnicode_FromString(error_cause_str);
+ 
+     g_free(error_cause_str);
+ 
+@@ -35,7 +35,7 @@ static PyObject *bt_bt2_format_bt_error(const bt_error *error)
+                                 BT_COMMON_COLOR_WHEN_NEVER);
+     BT_ASSERT(error_str);
+ 
+-    py_error_str = PyString_FromString(error_str);
++    py_error_str = PyUnicode_FromString(error_str);
+ 
+     g_free(error_str);
+ 
diff --git a/meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb b/meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb
index 7c151bf729..9962ef377c 100644
--- a/meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb
+++ b/meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb
@@ -15,6 +15,7 @@ SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http
            file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \
            file://external-python-tests.patch \
            file://0001-src-explicitly-only-build-shared-plugins.patch \
+           file://0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch \
            "
 SRCREV = "d0e946a71faf5f0c2d7f1fb5b92a369983e9cf10"
 UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"


  parent reply	other threads:[~2026-08-11 13:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 15:45 [PATCH] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-10 21:02 ` [OE-core] " Richard Purdie
2026-08-11  6:12 ` [PATCH v2 0/2] " Jaipaul Cheernam
2026-08-11  6:12   ` [PATCH v2 1/2] " Jaipaul Cheernam
2026-08-11 10:25     ` [OE-core] " Richard Purdie
2026-08-11 11:15       ` Jaipaul Cheernam
2026-08-11  6:12   ` [PATCH v2 2/2] babeltrace2: fix build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 11:11 ` [PATCH v3 0/4] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 1/4] " Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 2/4] babeltrace2: fix build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 3/4] u-boot-tools: fix pylibfdt " Jaipaul Cheernam
2026-08-11 12:58     ` [OE-core] " Mathieu Dubois-Briand
2026-08-11 13:38     ` Quentin Schulz
2026-08-11 11:11   ` [PATCH v3 4/4] python3-dtc: fix " Jaipaul Cheernam
2026-08-11 13:51 ` [PATCH v4 0/4] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-11 13:51   ` [PATCH v4 1/4] " Jaipaul Cheernam
2026-08-11 13:51   ` Jaipaul Cheernam [this message]
2026-08-11 13:51   ` [PATCH v4 3/4] u-boot-tools: fix pylibfdt build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 13:52   ` [PATCH v4 4/4] python3-dtc: fix " Jaipaul Cheernam
2026-08-12  9:11     ` [OE-core] " Mathieu Dubois-Briand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260811135200.18942-3-jaipaul.cheernam@est.tech \
    --to=jaipaul.cheernam@est.tech \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox