From c182ae0b978b27778728aa7c5c558ca876ce5cd4 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 14:08:32 -0800 Subject: [PATCH 01/16] Remove Python 3.3 support --- src/twisted/python/_setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/twisted/python/_setup.py b/src/twisted/python/_setup.py index 1fdc64b9ff7..a6ca9d91928 100644 --- a/src/twisted/python/_setup.py +++ b/src/twisted/python/_setup.py @@ -65,7 +65,6 @@ classifiers=[ "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", From 0d495efd5da88264ea50d7f5fb2d396a02d6a795 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 14:12:09 -0800 Subject: [PATCH 02/16] Remove support for Python 3.3 --- src/twisted/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/twisted/__init__.py b/src/twisted/__init__.py index 720fec979da..8a16f90affb 100644 --- a/src/twisted/__init__.py +++ b/src/twisted/__init__.py @@ -14,8 +14,8 @@ def _checkRequirements(): version = getattr(sys, "version_info", (0,)) if version < (2, 7): raise ImportError("Twisted requires Python 2.7 or later.") - elif version >= (3, 0) and version < (3, 3): - raise ImportError("Twisted on Python 3 requires Python 3.3 or later.") + elif version >= (3, 0) and version < (3, 4): + raise ImportError("Twisted on Python 3 requires Python 3.4 or later.") _checkRequirements() From 9e5acc7b938a32f6c3477321f8734ee09514139d Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 14:41:53 -0800 Subject: [PATCH 03/16] Remove Python 3.3 special case --- src/twisted/internet/abstract.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/twisted/internet/abstract.py b/src/twisted/internet/abstract.py index 9e374f69133..21a30d7128c 100644 --- a/src/twisted/internet/abstract.py +++ b/src/twisted/internet/abstract.py @@ -20,15 +20,10 @@ import sys if _PY3: - if (sys.version_info.major, sys.version_info.minor) == (3, 3): - # Python 3.3 cannot join bytes and memoryviews - def _concatenate(bObj, offset, bArray): - return bObj[offset:] + b"".join(bArray) - else: - # Python 3.4+ can join bytes and memoryviews; using a - # memoryview prevents the slice from copying - def _concatenate(bObj, offset, bArray): - return b''.join([memoryview(bObj)[offset:]] + bArray) + # Python 3.4+ can join bytes and memoryviews; using a + # memoryview prevents the slice from copying + def _concatenate(bObj, offset, bArray): + return b''.join([memoryview(bObj)[offset:]] + bArray) else: from __builtin__ import buffer From 69120db61e97df5288e14fdeed36757da411c52e Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 15:20:03 -0800 Subject: [PATCH 04/16] Remove Python 3.3 build --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c43e4e2772..ee634279e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,6 @@ matrix: env: TOXENV=py27-alldeps-withcov-posix,codecov-publish - python: 2.7 env: TOXENV=py27-nodeps-withcov-posix,codecov-publish - - python: 3.3 - env: TOXENV=py33-alldeps-withcov-posix,codecov-publish - python: 3.4 env: TOXENV=py34-alldeps-withcov-posix,codecov-publish - python: 3.5 From 2048b60595df43170792b83597fcc83b89300f31 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 15:51:50 -0800 Subject: [PATCH 05/16] Add newsfragment --- src/twisted/newsfragments/9352.removal | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/twisted/newsfragments/9352.removal diff --git a/src/twisted/newsfragments/9352.removal b/src/twisted/newsfragments/9352.removal new file mode 100644 index 00000000000..8a266065981 --- /dev/null +++ b/src/twisted/newsfragments/9352.removal @@ -0,0 +1 @@ +Python 3.3 is no longer supported. From a95383611780b98a07c06f83f08d461db5e7594a Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 15:57:41 -0800 Subject: [PATCH 06/16] Note that Twisted 17.9.0 is the last release which supports Python 3.3. --- NEWS.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index c6a01bdf83b..b2568bce73c 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -6,6 +6,9 @@ http://twistedmatrix.com/trac/ticket/ Twisted 17.9.0 (2017-09-23) =========================== +This is the last Twisted release where Python 3.3 is supported, on any +platform. + Features -------- From 51272035b85dab5607e0e1ae3ee363038bf902fa Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 16:17:36 -0800 Subject: [PATCH 07/16] Fail if we try to install on an unsupported Python version. --- setup.py | 5 +++++ src/twisted/__init__.py | 11 +---------- src/twisted/_checkrequirements.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/twisted/_checkrequirements.py diff --git a/setup.py b/setup.py index c050aa17fb3..d8ada1814af 100755 --- a/setup.py +++ b/setup.py @@ -13,6 +13,11 @@ if __name__ == "__main__": + _checkRequirements = {} + with open('src/twisted/_checkrequirements.py') as f: + exec(f.read(), _checkRequirements) + _checkRequirements["_checkRequirements"]() + _setup = {} with open('src/twisted/python/_setup.py') as f: exec(f.read(), _setup) diff --git a/src/twisted/__init__.py b/src/twisted/__init__.py index 8a16f90affb..6f3d83868e7 100644 --- a/src/twisted/__init__.py +++ b/src/twisted/__init__.py @@ -7,16 +7,7 @@ Twisted: The Framework Of Your Internet. """ -def _checkRequirements(): - # Don't allow the user to run a version of Python we don't support. - import sys - - version = getattr(sys, "version_info", (0,)) - if version < (2, 7): - raise ImportError("Twisted requires Python 2.7 or later.") - elif version >= (3, 0) and version < (3, 4): - raise ImportError("Twisted on Python 3 requires Python 3.4 or later.") - +from twisted._checkrequirements import _checkRequirements _checkRequirements() # setup version diff --git a/src/twisted/_checkrequirements.py b/src/twisted/_checkrequirements.py new file mode 100644 index 00000000000..28e26be75ee --- /dev/null +++ b/src/twisted/_checkrequirements.py @@ -0,0 +1,14 @@ +# -*- test-case-name: twisted -*- + +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. + +def _checkRequirements(): + # Don't allow the user to run a version of Python we don't support. + import sys + + version = getattr(sys, "version_info", (0,)) + if version < (2, 7): + raise ImportError("Twisted requires Python 2.7 or later.") + elif version >= (3, 0) and version < (3, 4): + raise ImportError("Twisted on Python 3 requires Python 3.4 or later.") From 1f728129eced8c11d51d3d2dfa4aafe6b9a43983 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 16:56:37 -0800 Subject: [PATCH 08/16] Drop support for Python 3.3 --- src/twisted/test/test_twisted.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/twisted/test/test_twisted.py b/src/twisted/test/test_twisted.py index e2c7cbc859e..8d2fee0d5f9 100644 --- a/src/twisted/test/test_twisted.py +++ b/src/twisted/test/test_twisted.py @@ -160,8 +160,8 @@ class RequirementsTests(TestCase): """ unsupportedPythonVersion = (2, 6) supportedPythonVersion = (2, 7) - Py3unsupportedPythonVersion = (3, 2) - Py3supportedPythonVersion = (3, 3) + Py3unsupportedPythonVersion = (3, 3) + Py3supportedPythonVersion = (3, 4) def setUp(self): From eb869ab24c67d21beae3c3fa1b1da8ae5659a85f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Sun, 17 Dec 2017 17:19:41 -0800 Subject: [PATCH 09/16] Remove unused import --- src/twisted/internet/abstract.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/twisted/internet/abstract.py b/src/twisted/internet/abstract.py index 21a30d7128c..4b560dc4e6b 100644 --- a/src/twisted/internet/abstract.py +++ b/src/twisted/internet/abstract.py @@ -17,8 +17,6 @@ from twisted.python import reflect, failure from twisted.internet import interfaces, main -import sys - if _PY3: # Python 3.4+ can join bytes and memoryviews; using a # memoryview prevents the slice from copying From b13e6aa407b5964a8597bc7fbf0f52b4b9c5799c Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 15:51:18 -0500 Subject: [PATCH 10/16] Convert comment to docstring --- src/twisted/_checkrequirements.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/twisted/_checkrequirements.py b/src/twisted/_checkrequirements.py index 28e26be75ee..0dc5f43c760 100644 --- a/src/twisted/_checkrequirements.py +++ b/src/twisted/_checkrequirements.py @@ -4,7 +4,9 @@ # See LICENSE for details. def _checkRequirements(): - # Don't allow the user to run a version of Python we don't support. + """ + Do not allow the user to run a version of Python we don't support. + """ import sys version = getattr(sys, "version_info", (0,)) From ba8cb897667b2afdefc663b673d38ba435cfa64d Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 16:04:34 -0500 Subject: [PATCH 11/16] Move check for Python version into _setup.py --- setup.py | 5 ----- src/twisted/python/_setup.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index d8ada1814af..c050aa17fb3 100755 --- a/setup.py +++ b/setup.py @@ -13,11 +13,6 @@ if __name__ == "__main__": - _checkRequirements = {} - with open('src/twisted/_checkrequirements.py') as f: - exec(f.read(), _checkRequirements) - _checkRequirements["_checkRequirements"]() - _setup = {} with open('src/twisted/python/_setup.py') as f: exec(f.read(), _setup) diff --git a/src/twisted/python/_setup.py b/src/twisted/python/_setup.py index a6ca9d91928..c82088fa7fa 100644 --- a/src/twisted/python/_setup.py +++ b/src/twisted/python/_setup.py @@ -197,11 +197,27 @@ def __init__(self, *args, **kwargs): +def _checkPythonVersion(): + """ + Fail if we detect a version of Python we don't support. + """ + import sys + + version = getattr(sys, "version_info", (0,)) + if version < (2, 7): + raise ImportError("Twisted requires Python 2.7 or later.") + elif version >= (3, 0) and version < (3, 4): + raise ImportError("Twisted on Python 3 requires Python 3.4 or later.") + + + def getSetupArgs(extensions=_EXTENSIONS): """ @return: The keyword arguments to be used the the setup method. @rtype: L{dict} """ + _checkPythonVersion() + arguments = STATIC_PACKAGE_METADATA.copy() # This is a workaround for distutils behavior; ext_modules isn't From d4050c2d617b51aabb78159ad9bf3d5bb473424f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 16:05:00 -0500 Subject: [PATCH 12/16] Move check for Python version into _setup.py --- src/twisted/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/twisted/__init__.py b/src/twisted/__init__.py index 6f3d83868e7..ebff4c2301d 100644 --- a/src/twisted/__init__.py +++ b/src/twisted/__init__.py @@ -7,9 +7,6 @@ Twisted: The Framework Of Your Internet. """ -from twisted._checkrequirements import _checkRequirements -_checkRequirements() - # setup version from twisted._version import __version__ as version __version__ = version.short() From d5842608f9304e4b190d4884b0b1a51b1fbdf6a0 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 16:06:39 -0500 Subject: [PATCH 13/16] Remove unused file --- src/twisted/_checkrequirements.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/twisted/_checkrequirements.py diff --git a/src/twisted/_checkrequirements.py b/src/twisted/_checkrequirements.py deleted file mode 100644 index 0dc5f43c760..00000000000 --- a/src/twisted/_checkrequirements.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- test-case-name: twisted -*- - -# Copyright (c) Twisted Matrix Laboratories. -# See LICENSE for details. - -def _checkRequirements(): - """ - Do not allow the user to run a version of Python we don't support. - """ - import sys - - version = getattr(sys, "version_info", (0,)) - if version < (2, 7): - raise ImportError("Twisted requires Python 2.7 or later.") - elif version >= (3, 0) and version < (3, 4): - raise ImportError("Twisted on Python 3 requires Python 3.4 or later.") From 532c54dc90fac123242265b6e9bf358c6e7ea388 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 16:13:04 -0500 Subject: [PATCH 14/16] Use _checkPythonVersion --- src/twisted/test/test_twisted.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/twisted/test/test_twisted.py b/src/twisted/test/test_twisted.py index 8d2fee0d5f9..b68e7b22368 100644 --- a/src/twisted/test/test_twisted.py +++ b/src/twisted/test/test_twisted.py @@ -13,7 +13,7 @@ from types import ModuleType -from twisted import _checkRequirements +from twisted.python._setup import _checkPythonVersion from twisted.python.compat import _PY3 from twisted.python import reflect from twisted.trial.unittest import TestCase @@ -181,12 +181,12 @@ def tearDown(self): def test_oldPython(self): """ - L{_checkRequirements} raises L{ImportError} when run on a version of + L{_checkPythonVersion} raises L{ImportError} when run on a version of Python that is too old. """ sys.version_info = self.unsupportedPythonVersion with self.assertRaises(ImportError) as raised: - _checkRequirements() + _checkPythonVersion() self.assertEqual("Twisted requires Python %d.%d or later." % self.supportedPythonVersion, str(raised.exception)) @@ -194,21 +194,21 @@ def test_oldPython(self): def test_newPython(self): """ - L{_checkRequirements} returns L{None} when run on a version of Python + L{_checkPythonVersion} returns L{None} when run on a version of Python that is sufficiently new. """ sys.version_info = self.supportedPythonVersion - self.assertIsNone(_checkRequirements()) + self.assertIsNone(_checkPythonVersion()) def test_oldPythonPy3(self): """ - L{_checkRequirements} raises L{ImportError} when run on a version of + L{_checkPythonVersion} raises L{ImportError} when run on a version of Python that is too old. """ sys.version_info = self.Py3unsupportedPythonVersion with self.assertRaises(ImportError) as raised: - _checkRequirements() + _checkPythonVersion() self.assertEqual("Twisted on Python 3 requires Python %d.%d or later." % self.Py3supportedPythonVersion, str(raised.exception)) @@ -216,11 +216,11 @@ def test_oldPythonPy3(self): def test_newPythonPy3(self): """ - L{_checkRequirements} returns L{None} when run on a version of Python + L{_checkPythonVersion} returns L{None} when run on a version of Python that is sufficiently new. """ sys.version_info = self.Py3supportedPythonVersion - self.assertIsNone(_checkRequirements()) + self.assertIsNone(_checkPythonVersion()) From b561b519da74dd34ee37f7bb5aa39db94240468c Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 17:47:16 -0500 Subject: [PATCH 15/16] Remove unnecessary import --- src/twisted/python/_setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/twisted/python/_setup.py b/src/twisted/python/_setup.py index c82088fa7fa..e5a3444f2ec 100644 --- a/src/twisted/python/_setup.py +++ b/src/twisted/python/_setup.py @@ -201,8 +201,6 @@ def _checkPythonVersion(): """ Fail if we detect a version of Python we don't support. """ - import sys - version = getattr(sys, "version_info", (0,)) if version < (2, 7): raise ImportError("Twisted requires Python 2.7 or later.") From 755d804b0b73e9bcfb4f6a98907d4657a1a1f22f Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Wed, 3 Jan 2018 20:55:12 -0500 Subject: [PATCH 16/16] Use format string --- src/twisted/python/_setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/twisted/python/_setup.py b/src/twisted/python/_setup.py index e5a3444f2ec..6f62d445a9e 100644 --- a/src/twisted/python/_setup.py +++ b/src/twisted/python/_setup.py @@ -211,6 +211,7 @@ def _checkPythonVersion(): def getSetupArgs(extensions=_EXTENSIONS): """ + @return: The keyword arguments to be used the the setup method. @rtype: L{dict} """ @@ -354,8 +355,8 @@ def _check_header(self, header_name): Check if the given header can be included by trying to compile a file that contains only an #include line. """ - self.compiler.announce("checking for %s ..." % header_name, 0) - return self._compile_helper("#include <%s>\n" % header_name) + self.compiler.announce("checking for {} ...".format(header_name), 0) + return self._compile_helper("#include <{}>\n".format(header_name))