Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Python 3.3 #943

Merged
merged 17 commits into from
Jan 6, 2018
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ http://twistedmatrix.com/trac/ticket/<number>
Twisted 17.9.0 (2017-09-23)
===========================

This is the last Twisted release where Python 3.3 is supported, on any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like we are re-writing history here.
I think that we should not touch previous release notes.

So we should just update the release notes for the next (future) release and drop support after that...
but I am not familiar with the process of dropping a python version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Python 2.6 support was dropped, the NEWS.rst file was modified after the fact to update this: http://twistedmatrix.com/trac/ticket/8651

Since that seemed to be OK, I did it here.

Dropping support for a Python release happens so infrequently, that I thought it was OK.

platform.

Features
--------

Expand Down
12 changes: 0 additions & 12 deletions src/twisted/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
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, 3):
raise ImportError("Twisted on Python 3 requires Python 3.3 or later.")

_checkRequirements()

# setup version
from twisted._version import __version__ as version
__version__ = version.short()
15 changes: 4 additions & 11 deletions src/twisted/internet/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@
from twisted.python import reflect, failure
from twisted.internet import interfaces, main

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

Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/9352.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.3 is no longer supported.
17 changes: 16 additions & 1 deletion src/twisted/python/_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -198,11 +197,27 @@ def __init__(self, *args, **kwargs):



def _checkPythonVersion():
"""
Fail if we detect a version of Python we don't support.
"""
import sys
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this import can be removed


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
Expand Down
22 changes: 11 additions & 11 deletions src/twisted/test/test_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -181,46 +181,46 @@ 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))


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))


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())



Expand Down