From a82c1b943b6837c3a99bc1390e83a0f1a23d2ac2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 17:07:18 +1200 Subject: [PATCH] Drop support for Python 3.0 to 3.3 See #701. --- Doc/Manual/Python.html | 6 +++--- Lib/python/builtin.swg | 5 +---- Lib/python/pyinit.swg | 9 --------- Lib/python/pyrun.swg | 4 ++++ Lib/python/pystrings.swg | 4 ---- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 9c43fb3fe..46a41a4d8 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -149,9 +149,9 @@

This chapter describes SWIG's support of Python. SWIG is compatible -with most recent Python versions (Python 2.7 and Python 3.x). If you still -need to generate bindings which work with older versions of Python, you'll have -to use SWIG 3.0.x. +with all recent Python versions (Python 2.7 and Python >= 3.4). If you +still need to generate bindings which work with older versions of Python, +you'll have to use SWIG 3.0.x.

diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 98fbfe4c6..4e39610fa 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -13,12 +13,9 @@ SWIGINTERN Py_hash_t SWIG_PyNumber_AsPyHash(PyObject *obj) { Py_hash_t result = -1; #if PY_VERSION_HEX < 0x03020000 -#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) result = PyInt_AsLong(obj); - else -#endif - if (PyLong_Check(obj)) + else if (PyLong_Check(obj)) result = PyLong_AsLong(obj); #else if (PyNumber_Check(obj)) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 550477edf..2d4fe2fb1 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -329,16 +329,7 @@ SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { -# if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, -# else - { - PyObject_HEAD_INIT(NULL) - NULL, /* m_init */ - 0, /* m_index */ - NULL, /* m_copy */ - }, -# endif (char *) SWIG_name, NULL, -1, diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index a19ab54cf..3bf16b423 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -11,6 +11,10 @@ # error "This version of SWIG only supports Python >= 2.7" #endif +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03040000 +# error "This version of SWIG only supports Python 3 >= 3.4" +#endif + /* Common SWIG API */ /* for raw pointers */ diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 301e0f3e1..ac87d07ab 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -137,11 +137,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) return PyBytes_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#else -%#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape"); -%#else - return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); -%#endif %#endif %#else return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t));