Fix FTBFS with Python 3.13.

This solves issue #26.

Signed-off-by: François Andriot <albator78@libertysurf.fr>
pull/27/head
François Andriot 11 months ago committed by François Andriot
parent dc7ba7a6d7
commit 4ab9fdc0fc

@ -1691,7 +1691,7 @@ static PyObject *sip_api_call_method(int *isErr, PyObject *method,
va_start(va,fmt); va_start(va,fmt);
if ((args = PyTuple_New(strlen(fmt))) != NULL && buildObject(args,fmt,va) != NULL) if ((args = PyTuple_New(strlen(fmt))) != NULL && buildObject(args,fmt,va) != NULL)
res = PyEval_CallObject(method,args); res = PyObject_CallObject(method,args);
else else
{ {
res = NULL; res = NULL;
@ -9635,18 +9635,37 @@ static PyObject *parseString_AsEncodedString(PyObject *bytes, PyObject *obj,
static int parseBytes_AsCharArray(PyObject *obj, const char **ap, static int parseBytes_AsCharArray(PyObject *obj, const char **ap,
SIP_SSIZE_T *aszp) SIP_SSIZE_T *aszp)
{ {
const char *a;
SIP_SSIZE_T asz;
if (obj == Py_None) if (obj == Py_None)
{ {
*ap = NULL; a = NULL;
*aszp = 0; asz = 0;
} }
else if (PyBytes_Check(obj)) else if (PyBytes_Check(obj))
{ {
*ap = PyBytes_AS_STRING(obj); a = PyBytes_AS_STRING(obj);
*aszp = PyBytes_GET_SIZE(obj); asz = PyBytes_GET_SIZE(obj);
} }
else if (PyObject_AsCharBuffer(obj, ap, aszp) < 0) else
return -1; {
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; return 0;
} }
@ -9665,13 +9684,24 @@ static int parseBytes_AsChar(PyObject *obj, char *ap)
chp = PyBytes_AS_STRING(obj); chp = PyBytes_AS_STRING(obj);
sz = PyBytes_GET_SIZE(obj); sz = PyBytes_GET_SIZE(obj);
} }
else if (PyObject_AsCharBuffer(obj, &chp, &sz) < 0) else
return -1; {
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) if (sz != 1)
return -1; return -1;
*ap = *chp; if (ap)
*ap = *chp;
return 0; return 0;
} }

@ -196,7 +196,7 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
{ {
PyObject *nsa, *xtype, *xvalue, *xtb, *resobj; PyObject *nsa, *xtype, *xvalue, *xtb, *resobj;
if ((resobj = PyEval_CallObject(sfunc, sa)) != NULL) if ((resobj = PyObject_CallObject(sfunc, sa)) != NULL)
{ {
Py_DECREF(sfunc); Py_DECREF(sfunc);
Py_XDECREF(sref); Py_XDECREF(sref);

Loading…
Cancel
Save