Browse Source

python-sip: fix compile error

Since the update of Python to version 3.11 in commit
738500c296c8b1206f20e94ca3e7c5932a6a0486 ("package/python3: bump to
version 3.11.0"), python-sip fails to compile with:

siplib.c: In function ‘sip_api_get_frame’:
siplib.c:13750:22: error: invalid use of undefined type ‘struct _frame’
13750 |         frame = frame->f_back;

This is due to a change in the Python C API, which is fixed by a new
patch. The patch can't be upstreamed, as SIP 4.x is no longer
maintained upstream.

Fixes:

  http://autobuild.buildroot.net/results/7b01739e7514e48c06182bc1804b32497ce2e414/

Signed-off-by: Ralf Dragon <hypnotoad@lindra.de>
[Thomas: improved commit log, reformatted patch using Git]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 3ef6884e6d59744d83649170822a4829eed146fc)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Ralf Dragon 1 year ago
parent
commit
fef6c598c5
1 changed files with 66 additions and 0 deletions
  1. 66 0
      package/python-sip/0002-siplib-fix-build-with-python-3.11.patch

+ 66 - 0
package/python-sip/0002-siplib-fix-build-with-python-3.11.patch

@@ -0,0 +1,66 @@
+From e8bbb7844c141b339ef0598decf2a808faa50f5e Mon Sep 17 00:00:00 2001
+From: Ralf Dragon <hypnotoad@lindra.de>
+Date: Sun, 17 Dec 2023 22:55:17 +0100
+Subject: [PATCH] siplib: fix build with python >= 3.11
+
+With python 3.11, the PyFrameObject structure members have been
+removed from the public C API:
+
+https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
+https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding
+
+This patch migrates to the opaque PyFrameObject.
+
+Upstream: Not Applicable, SIP 4.x is no longer maintained
+Signed-off-by: Ralf Dragon <hypnotoad@lindra.de>
+---
+ siplib/sip.h    | 2 +-
+ siplib/siplib.c | 8 ++++----
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/siplib/sip.h b/siplib/sip.h
+index 251b122..b9d8ea2 100644
+--- a/siplib/sip.h
++++ b/siplib/sip.h
+@@ -1799,7 +1799,7 @@ typedef struct _sipAPIDef {
+     int (*api_get_time)(PyObject *, sipTimeDef *);
+     PyObject *(*api_from_time)(const sipTimeDef *);
+     int (*api_is_user_type)(const sipWrapperType *);
+-    struct _frame *(*api_get_frame)(int);
++    PyFrameObject *(*api_get_frame)(int);
+     int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
+     PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
+     void (*api_unicode_write)(int, void *, int, unsigned);
+diff --git a/siplib/siplib.c b/siplib/siplib.c
+index db52b68..a297855 100644
+--- a/siplib/siplib.c
++++ b/siplib/siplib.c
+@@ -448,7 +448,7 @@ static PyObject *sip_api_from_datetime(const sipDateDef *date,
+ static int sip_api_get_time(PyObject *obj, sipTimeDef *time);
+ static PyObject *sip_api_from_time(const sipTimeDef *time);
+ static int sip_api_is_user_type(const sipWrapperType *wt);
+-static struct _frame *sip_api_get_frame(int);
++static PyFrameObject *sip_api_get_frame(int);
+ static int sip_api_check_plugin_for_type(const sipTypeDef *td,
+         const char *name);
+ static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
+@@ -13741,13 +13741,13 @@ static int sip_api_is_user_type(const sipWrapperType *wt)
+ /*
+  * Return a frame from the execution stack.
+  */
+-static struct _frame *sip_api_get_frame(int depth)
++static PyFrameObject *sip_api_get_frame(int depth)
+ {
+-    struct _frame *frame = PyEval_GetFrame();
++    PyFrameObject *frame = PyEval_GetFrame();
+ 
+     while (frame != NULL && depth > 0)
+     {
+-        frame = frame->f_back;
++        frame = PyFrame_GetBack(frame);
+         --depth;
+     }
+ 
+-- 
+2.43.0
+