From f7dbc054dbe09a7392504ec3d1fb78c2bb1c7968 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 24 Jan 2017 07:48:05 +0100 Subject: [PATCH] more python 2 removal --- python/core/conversions.sip | 63 +++---------------- .../ext-libs/pyspatialite/src/sqlitecompat.h | 8 +-- 2 files changed, 8 insertions(+), 63 deletions(-) diff --git a/python/core/conversions.sip b/python/core/conversions.sip index 28c3120e880..5d1e66ba26a 100644 --- a/python/core/conversions.sip +++ b/python/core/conversions.sip @@ -24,13 +24,6 @@ which are not wrapped by PyQt: %ModuleHeaderCode -// From Python 2.5, some functions use Py_ssize_t instead of int -// thus this typedef is for maintaining backward compatibility -// for older versions of Python -#if (PY_VERSION_HEX < 0x02050000) -typedef int Py_ssize_t; -#endif - %End @@ -766,9 +759,6 @@ template - - - %MappedType QMap { %TypeHeaderCode @@ -820,12 +810,7 @@ template %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif - // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -922,12 +907,7 @@ template %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif - // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -1026,11 +1006,7 @@ template %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -1127,11 +1103,7 @@ template %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -1240,11 +1212,7 @@ template %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -1323,11 +1291,7 @@ template const int t1 = i.key(); TYPE2 * t2 = i.value(); -#if (PY_VERSION_HEX < 0x03000000) - PyObject *t1obj = PyInt_FromSize_t(t1); -#else PyObject *t1obj = PyLong_FromSize_t(t1); -#endif PyObject *t2obj = sipConvertFromType(t2, sipType_TYPE2, sipTransferObj); if (PyDict_GetItem(d, t1obj) == NULL) { @@ -1367,11 +1331,7 @@ template %ConvertToTypeCode // Convert from Python: PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif // Check the type if that is all that is required. if (sipIsErr == NULL) @@ -1473,12 +1433,10 @@ template return d; %End + %ConvertToTypeCode -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif + QList < QPair< QString, QList > > *qm = new QList < QPair< QString, QList > >; for ( i = 0; i < PyList_GET_SIZE(sipPy); i++ ) @@ -1542,12 +1500,10 @@ template return d; %End + %ConvertToTypeCode -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif + QList < QPair< QString, double > > *qm = new QList< QPair< QString, double > >; for ( i = 0; i < PyList_GET_SIZE(sipPy); i++ ) @@ -1603,12 +1559,10 @@ template return d; %End + %ConvertToTypeCode -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif + QList < QPair< QgsVectorLayer *, int > > *qm = new QList< QPair< QgsVectorLayer *, int > >; for ( i = 0; i < PyList_GET_SIZE(sipPy); i++ ) @@ -1755,13 +1709,10 @@ template return d; %End + %ConvertToTypeCode PyObject *t1obj, *t2obj; -#if PY_VERSION_HEX >= 0x02050000 Py_ssize_t i = 0; -#else - int i = 0; -#endif QMap *qm = new QMap; diff --git a/python/ext-libs/pyspatialite/src/sqlitecompat.h b/python/ext-libs/pyspatialite/src/sqlitecompat.h index 3408fc2119a..7eddb14acd4 100644 --- a/python/ext-libs/pyspatialite/src/sqlitecompat.h +++ b/python/ext-libs/pyspatialite/src/sqlitecompat.h @@ -1,3 +1,4 @@ + /* sqlitecompat.h - compatibility macros * * Copyright (C) 2006-2010 Gerhard Häring @@ -26,13 +27,6 @@ #ifndef PYSQLITE_COMPAT_H #define PYSQLITE_COMPAT_H -/* define Py_ssize_t for pre-2.5 versions of Python */ - -#if PY_VERSION_HEX < 0x02050000 -typedef int Py_ssize_t; -typedef int (*lenfunc)(PyObject*); -#endif - /* define PyDict_CheckExact for pre-2.4 versions of Python */ #ifndef PyDict_CheckExact