summaryrefslogtreecommitdiffstats
path: root/siplib/voidptr.c
diff options
context:
space:
mode:
authoraneejit1 <aneejit1@gmail.com>2022-04-19 00:17:45 +0000
committerSlávek Banko <slavek.banko@axis.cz>2022-04-21 16:29:57 +0200
commit5b12d262dc940b6fe9e2766988917665c970318d (patch)
tree1ff5dc43f32d509aa1348ceac40e5ec6b372f028 /siplib/voidptr.c
parent299bacc2dd874a55eb2e0d430a439b6fb5895e13 (diff)
downloadsip4-tqt-5b12d262dc940b6fe9e2766988917665c970318d.tar.gz
sip4-tqt-5b12d262dc940b6fe9e2766988917665c970318d.zip
Updates for Python 3 Support
The following changes have been made to support Python 3: - in sip-tqt.h, remove the cast in the "sipConvertFromSliceObject" macro in versions 3.2+ as the API changed causing a compile error; - in voidptr.h, alter the precompile conditions to remove the PyCObject API cals for version 3.2+ (causes runtime symbol resolution error) and amend the flags for "asstring"; - alter module import process in siplib.c to avoid re-loading an already loaded module. Signed-off-by: aneejit1 <aneejit1@gmail.com> Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'siplib/voidptr.c')
-rw-r--r--siplib/voidptr.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/siplib/voidptr.c b/siplib/voidptr.c
index 65d4fe9..50cafb2 100644
--- a/siplib/voidptr.c
+++ b/siplib/voidptr.c
@@ -195,6 +195,7 @@ static PyObject *sipVoidPtr_ascapsule(sipVoidPtrObject *v, PyObject *arg)
#endif
+#if defined(SIP_SUPPORT_PYCOBJECT)
/*
* Implement ascobject() for the type.
*/
@@ -202,6 +203,7 @@ static PyObject *sipVoidPtr_ascobject(sipVoidPtrObject *v, PyObject *arg)
{
return PyCObject_FromVoidPtr(v->voidptr, NULL);
}
+#endif
/*
@@ -311,8 +313,10 @@ static PyMethodDef sipVoidPtr_Methods[] = {
#if defined(SIP_USE_PYCAPSULE)
{"ascapsule", (PyCFunction)sipVoidPtr_ascapsule, METH_NOARGS, NULL},
#endif
+#if defined(SIP_SUPPORT_PYCOBJECT)
{"ascobject", (PyCFunction)sipVoidPtr_ascobject, METH_NOARGS, NULL},
- {"asstring", (PyCFunction)sipVoidPtr_asstring, METH_KEYWORDS, NULL},
+#endif
+ {"asstring", (PyCFunction)sipVoidPtr_asstring, METH_VARARGS|METH_KEYWORDS, NULL},
{"getsize", (PyCFunction)sipVoidPtr_getsize, METH_NOARGS, NULL},
{"setsize", (PyCFunction)sipVoidPtr_setsize, METH_O, NULL},
{"getwriteable", (PyCFunction)sipVoidPtr_getwriteable, METH_NOARGS, NULL},
@@ -456,9 +460,11 @@ void *sip_api_convert_to_void_ptr(PyObject *obj)
if (PyCapsule_CheckExact(obj))
return PyCapsule_GetPointer(obj, NULL);
#endif
-
+#if defined(SIP_SUPPORT_PYCOBJECT)
if (PyCObject_Check(obj))
return PyCObject_AsVoidPtr(obj);
+#endif
+
#if PY_MAJOR_VERSION >= 3
return PyLong_AsVoidPtr(obj);
@@ -544,8 +550,10 @@ static int vp_convertor(PyObject *arg, struct vp_values *vp)
else if (PyCapsule_CheckExact(arg))
ptr = PyCapsule_GetPointer(arg, NULL);
#endif
+#if defined(SIP_SUPPORT_PYCOBJECT)
else if (PyCObject_Check(arg))
ptr = PyCObject_AsVoidPtr(arg);
+#endif
else if (PyObject_TypeCheck(arg, &sipVoidPtr_Type))
{
ptr = ((sipVoidPtrObject *)arg)->voidptr;