1From e8bbb7844c141b339ef0598decf2a808faa50f5e Mon Sep 17 00:00:00 2001
2From: Ralf Dragon <hypnotoad@lindra.de>
3Date: Sun, 17 Dec 2023 22:55:17 +0100
4Subject: [PATCH] siplib: fix build with python >= 3.11
5
6With python 3.11, the PyFrameObject structure members have been
7removed from the public C API:
8
9https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
10https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding
11
12This patch migrates to the opaque PyFrameObject.
13
14Upstream: Not Applicable, SIP 4.x is no longer maintained
15Signed-off-by: Ralf Dragon <hypnotoad@lindra.de>
16---
17 siplib/sip.h    | 2 +-
18 siplib/siplib.c | 8 ++++----
19 2 files changed, 5 insertions(+), 5 deletions(-)
20
21diff --git a/siplib/sip.h b/siplib/sip.h
22index 251b122..b9d8ea2 100644
23--- a/siplib/sip.h
24+++ b/siplib/sip.h
25@@ -1799,7 +1799,7 @@ typedef struct _sipAPIDef {
26     int (*api_get_time)(PyObject *, sipTimeDef *);
27     PyObject *(*api_from_time)(const sipTimeDef *);
28     int (*api_is_user_type)(const sipWrapperType *);
29-    struct _frame *(*api_get_frame)(int);
30+    PyFrameObject *(*api_get_frame)(int);
31     int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
32     PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
33     void (*api_unicode_write)(int, void *, int, unsigned);
34diff --git a/siplib/siplib.c b/siplib/siplib.c
35index db52b68..a297855 100644
36--- a/siplib/siplib.c
37+++ b/siplib/siplib.c
38@@ -448,7 +448,7 @@ static PyObject *sip_api_from_datetime(const sipDateDef *date,
39 static int sip_api_get_time(PyObject *obj, sipTimeDef *time);
40 static PyObject *sip_api_from_time(const sipTimeDef *time);
41 static int sip_api_is_user_type(const sipWrapperType *wt);
42-static struct _frame *sip_api_get_frame(int);
43+static PyFrameObject *sip_api_get_frame(int);
44 static int sip_api_check_plugin_for_type(const sipTypeDef *td,
45         const char *name);
46 static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
47@@ -13741,13 +13741,13 @@ static int sip_api_is_user_type(const sipWrapperType *wt)
48 /*
49  * Return a frame from the execution stack.
50  */
51-static struct _frame *sip_api_get_frame(int depth)
52+static PyFrameObject *sip_api_get_frame(int depth)
53 {
54-    struct _frame *frame = PyEval_GetFrame();
55+    PyFrameObject *frame = PyEval_GetFrame();
56
57     while (frame != NULL && depth > 0)
58     {
59-        frame = frame->f_back;
60+        frame = PyFrame_GetBack(frame);
61         --depth;
62     }
63
64--
652.43.0
66
67