From ffcc65d4f04190551de5c71c6f106cb92f9235ab Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 28 Nov 2017 10:11:42 +0200 Subject: [PATCH] Drop support for EOL Python 2.6 --- .gitignore | 1 + .travis.yml | 1 - doc/src/install.rst | 2 +- psycopg/python.h | 12 ++---------- setup.py | 20 ++++---------------- tests/test_connection.py | 3 +-- tests/test_sql.py | 2 -- tests/test_types_basic.py | 1 - tox.ini | 2 +- 9 files changed, 10 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 409bb3a7..d78118b8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ doc/html/* doc/psycopg2.txt scripts/pypi_docs_upload.py env +.idea .tox /rel /wheels diff --git a/.travis.yml b/.travis.yml index 4d558f17..6152a4bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ language: python python: - 2.7 - 3.6 - - 2.6 - 3.5 - 3.4 - 3.3 diff --git a/doc/src/install.rst b/doc/src/install.rst index 2993c7cb..c2c245a9 100644 --- a/doc/src/install.rst +++ b/doc/src/install.rst @@ -17,7 +17,7 @@ The current `!psycopg2` implementation supports: .. NOTE: keep consistent with setup.py and the /features/ page. -- Python 2 versions from 2.6 to 2.7 +- Python version 2.7 - Python 3 versions from 3.2 to 3.6 - PostgreSQL server versions from 7.4 to 10 - PostgreSQL client library version from 9.1 diff --git a/psycopg/python.h b/psycopg/python.h index cfb8dad3..b16c4b9d 100644 --- a/psycopg/python.h +++ b/psycopg/python.h @@ -31,8 +31,8 @@ #include #endif -#if PY_VERSION_HEX < 0x02060000 -# error "psycopg requires Python >= 2.6" +#if PY_VERSION_HEX < 0x02070000 +# error "psycopg requires Python >= 2.7" #endif /* hash() return size changed around version 3.2a4 on 64bit platforms. Before @@ -44,14 +44,6 @@ typedef long Py_hash_t; typedef unsigned long Py_uhash_t; #endif -/* Macros defined in Python 2.6 */ -#ifndef Py_REFCNT -#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) -#define PyVarObject_HEAD_INIT(x,n) PyObject_HEAD_INIT(x) n, -#endif - /* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */ #define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d" diff --git a/setup.py b/setup.py index 6ffae80a..f010ef5b 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,6 @@ License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) License :: OSI Approved :: Zope Public License Programming Language :: Python Programming Language :: Python :: 2 -Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.2 @@ -297,7 +296,7 @@ class psycopg_build_ext(build_ext): # For Python versions that use MSVC compiler 2008, re-insert the # manifest into the resulting .pyd file. - if self.compiler_is_msvc() and sysVer in ((2, 6), (2, 7), (3, 0), (3, 1), (3, 2)): + if self.compiler_is_msvc() and sysVer in ((2, 7), (3, 0), (3, 1), (3, 2)): platform = get_platform() # Default to the x86 manifest manifest = '_psycopg.vc9.x86.manifest' @@ -319,7 +318,6 @@ class psycopg_build_ext(build_ext): def finalize_win32(self): """Finalize build system configuration on win32 platform.""" - sysVer = sys.version_info[:2] # Add compiler-specific arguments: extra_compiler_args = [] @@ -335,17 +333,6 @@ class psycopg_build_ext(build_ext): # API code. extra_compiler_args.append('-fno-strict-aliasing') - # Force correct C runtime library linkage: - if sysVer <= (2, 3): - # Yes: 'msvcr60', rather than 'msvcrt', is the correct value - # on the line below: - self.libraries.append('msvcr60') - elif sysVer in ((2, 4), (2, 5)): - self.libraries.append('msvcr71') - # Beyond Python 2.5, we take our chances on the default C runtime - # library, because we don't know what compiler those future - # versions of Python will use. - for extension in ext: # ext is a global list of Extension objects extension.extra_compile_args.extend(extra_compiler_args) # End of add-compiler-specific arguments section. @@ -414,7 +401,7 @@ class psycopg_build_ext(build_ext): # *at least* PostgreSQL 7.4 is available (this is the only # 7.x series supported by psycopg 2) pgversion = pg_config_helper.query("version").split()[1] - except: + except Exception: pgversion = "7.4.0" verre = re.compile( @@ -619,7 +606,7 @@ try: f = open("README.rst") readme = f.read() f.close() -except: +except Exception: print("failed to read readme: ignoring...") readme = __doc__ @@ -633,6 +620,7 @@ setup(name="psycopg2", download_url=download_url, license="LGPL with exceptions or ZPL", platforms=["any"], + python_requires='>=2.7,!=3.0.*,!=3.1.*', description=readme.split("\n")[0], long_description="\n".join(readme.split("\n")[2:]).lstrip(), classifiers=[x for x in classifiers.split("\n") if x], diff --git a/tests/test_connection.py b/tests/test_connection.py index eff10650..f13df18d 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -352,8 +352,7 @@ class ParseDsnTestCase(ConnectingTestCase): "DSN with quoting parsed") # Can't really use assertRaisesRegexp() here since we need to - # make sure that secret is *not* exposed in the error messgage - # (and it also requires python >= 2.7). + # make sure that secret is *not* exposed in the error message. raised = False try: # unterminated quote after dbname: diff --git a/tests/test_sql.py b/tests/test_sql.py index e35bf32d..2e12ba63 100755 --- a/tests/test_sql.py +++ b/tests/test_sql.py @@ -32,7 +32,6 @@ from psycopg2 import sql class SqlFormatTests(ConnectingTestCase): - @skip_before_python(2, 7) def test_pos(self): s = sql.SQL("select {} from {}").format( sql.Identifier('field'), sql.Identifier('table')) @@ -91,7 +90,6 @@ class SqlFormatTests(ConnectingTestCase): def test_compose_badnargs(self): self.assertRaises(IndexError, sql.SQL("select {0};").format) - @skip_before_python(2, 7) def test_compose_badnargs_auto(self): self.assertRaises(IndexError, sql.SQL("select {};").format) self.assertRaises(ValueError, sql.SQL("select {} {1};").format, 10, 20) diff --git a/tests/test_types_basic.py b/tests/test_types_basic.py index 8d624c1a..b0af6daa 100755 --- a/tests/test_types_basic.py +++ b/tests/test_types_basic.py @@ -295,7 +295,6 @@ class TypesBasicTests(ConnectingTestCase): else: self.assertEqual(memoryview, type(o2)) - @testutils.skip_before_python(2, 7) def testAdaptMemoryview(self): o1 = memoryview(bytearray(range(256))) o2 = self.execute("select %s;", (o1,)) diff --git a/tox.ini b/tox.ini index 4a1129d5..17612e25 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py26, py27 +envlist = py27 [testenv] commands = make check