1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
From fa5e4646122884c24513931d95b363ee47f62520 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Andriot?= <francois.andriot@thalesgroup.com>
Date: Wed, 25 Sep 2024 20:51:56 +0200
Subject: [PATCH] Fix FTBFS with Python 3.13. This solves issue #26.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: François Andriot <albator78@libertysurf.fr>
(cherry picked from commit 4ab9fdc0fc73f41d54bab0c9030d9645ac0bf18e)
---
siplib/siplib.c | 50 +++++++++++++++++++++++++++++++++++++++----------
siplib/tqtlib.c | 2 +-
2 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/siplib/siplib.c b/siplib/siplib.c
index f2ac7be..27b9e35 100644
--- a/siplib/siplib.c
+++ b/siplib/siplib.c
@@ -1691,7 +1691,7 @@ static PyObject *sip_api_call_method(int *isErr, PyObject *method,
va_start(va,fmt);
if ((args = PyTuple_New(strlen(fmt))) != NULL && buildObject(args,fmt,va) != NULL)
- res = PyEval_CallObject(method,args);
+ res = PyObject_CallObject(method,args);
else
{
res = NULL;
@@ -9635,18 +9635,37 @@ static PyObject *parseString_AsEncodedString(PyObject *bytes, PyObject *obj,
static int parseBytes_AsCharArray(PyObject *obj, const char **ap,
SIP_SSIZE_T *aszp)
{
+ const char *a;
+ SIP_SSIZE_T asz;
+
if (obj == Py_None)
{
- *ap = NULL;
- *aszp = 0;
+ a = NULL;
+ asz = 0;
}
else if (PyBytes_Check(obj))
{
- *ap = PyBytes_AS_STRING(obj);
- *aszp = PyBytes_GET_SIZE(obj);
+ a = PyBytes_AS_STRING(obj);
+ asz = PyBytes_GET_SIZE(obj);
}
- else if (PyObject_AsCharBuffer(obj, ap, aszp) < 0)
- return -1;
+ else
+ {
+ Py_buffer view;
+
+ if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0)
+ return -1;
+
+ a = view.buf;
+ asz = view.len;
+
+ PyBuffer_Release(&view);
+ }
+
+ if (ap)
+ *ap = a;
+
+ if (aszp)
+ *aszp = asz;
return 0;
}
@@ -9665,13 +9684,24 @@ static int parseBytes_AsChar(PyObject *obj, char *ap)
chp = PyBytes_AS_STRING(obj);
sz = PyBytes_GET_SIZE(obj);
}
- else if (PyObject_AsCharBuffer(obj, &chp, &sz) < 0)
- return -1;
+ else
+ {
+ Py_buffer view;
+
+ if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0)
+ return -1;
+
+ chp = view.buf;
+ sz = view.len;
+
+ PyBuffer_Release(&view);
+ }
if (sz != 1)
return -1;
- *ap = *chp;
+ if (ap)
+ *ap = *chp;
return 0;
}
diff --git a/siplib/tqtlib.c b/siplib/tqtlib.c
index d59c138..1fa8cfa 100644
--- a/siplib/tqtlib.c
+++ b/siplib/tqtlib.c
@@ -196,7 +196,7 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
{
PyObject *nsa, *xtype, *xvalue, *xtb, *resobj;
- if ((resobj = PyEval_CallObject(sfunc, sa)) != NULL)
+ if ((resobj = PyObject_CallObject(sfunc, sa)) != NULL)
{
Py_DECREF(sfunc);
Py_XDECREF(sref);
--
2.49.1
|