summaryrefslogtreecommitdiffstats
path: root/siplib/sip.h
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 17:35:12 +0200
commit5e00e331b79ece72843aa62af1a79090d0997a0e (patch)
treec86eeb36924a75499d53d58417833b1f915eb6fe /siplib/sip.h
parentdb6ca2190e3e95ccd28b99e2b981cc8f16ccd628 (diff)
downloadsip4-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/sip.h')
-rw-r--r--siplib/sip.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/siplib/sip.h b/siplib/sip.h
index 3e9a3c6..48180a3 100644
--- a/siplib/sip.h
+++ b/siplib/sip.h
@@ -208,10 +208,14 @@ extern "C" {
#define SIPBytes_AS_STRING PyBytes_AS_STRING
#define SIPBytes_GET_SIZE PyBytes_GET_SIZE
-#if PY_MINOR_VERSION >= 1
+#if (PY_MAJOR_VERSION > 3) || ((PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 1))
#define SIP_USE_PYCAPSULE
#endif
+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 2)
+#define SIP_SUPPORT_PYCOBJECT
+#endif
+
#else
#define SIPLong_FromLong PyInt_FromLong
@@ -227,6 +231,8 @@ extern "C" {
#define SIP_USE_PYCAPSULE
#endif
+#define SIP_SUPPORT_PYCOBJECT
+
#endif
#if !defined(Py_REFCNT)
@@ -1465,9 +1471,15 @@ typedef struct _sipTQtAPI {
#define sipIsExactWrappedType(wt) (sipTypeAsPyTypeObject((wt)->type) == (PyTypeObject *)(wt))
+#if PY_VERSION_HEX >= 0x03020000
+#define sipConvertFromSliceObject(o,len,start,stop,step,slen) \
+ PySlice_GetIndicesEx((o), (len), (start), (stop), \
+ (step), (slen))
+#else
#define sipConvertFromSliceObject(o,len,start,stop,step,slen) \
PySlice_GetIndicesEx((PySliceObject *)(o), (len), (start), (stop), \
(step), (slen))
+#endif
/*