diff options
| author | aneejit1 <aneejit1@gmail.com> | 2022-04-19 00:17:45 +0000 |
|---|---|---|
| committer | Slávek Banko <slavek.banko@axis.cz> | 2022-04-21 17:35:12 +0200 |
| commit | 5e00e331b79ece72843aa62af1a79090d0997a0e (patch) | |
| tree | c86eeb36924a75499d53d58417833b1f915eb6fe /siplib/voidptr.c | |
| parent | db6ca2190e3e95ccd28b99e2b981cc8f16ccd628 (diff) | |
| download | sip4-tqt-5e00e331.tar.gz sip4-tqt-5e00e331.zip | |
Updates for Python 3 Supportr14.0.12
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>
(cherry picked from commit 5b12d262dc940b6fe9e2766988917665c970318d)
Diffstat (limited to 'siplib/voidptr.c')
| -rw-r--r-- | siplib/voidptr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/siplib/voidptr.c b/siplib/voidptr.c index fc26046..dd7e039 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; |
