Skip to content

Commit

Permalink
drop support for python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Aug 16, 2023
1 parent 9a2ea00 commit d05751f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 99 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
# end to end functional test usage for non-distributed trial runs.
# When updating the minimum Python version here, also update the
# `python_requires` from `setup.cfg`.
- python-version: '3.7.1'
- python-version: '3.8.0'
tox-env: 'nodeps-withcov-posix'
job-name: 'nodeps-test'

Expand All @@ -113,7 +113,7 @@ jobs:
# We go with latest micro release for the smallest minor release
# that we support.
# This is also used to run tests with minimum dependency versions.
- python-version: '3.7'
- python-version: '3.8'
noipv6: '-noipv6'
tox-env: 'mindeps-withcov-posix'
job-name: 'minimum-deps-noipv6'
Expand All @@ -137,7 +137,7 @@ jobs:
tox-env: 'macos-withcov-alldeps'

# Windows, minimum Python version with select reactor.
- python-version: '3.7'
- python-version: '3.8'
runs-on: 'windows-2022'
tox-env: 'alldeps-withcov-windows'
job-name: 'win-default-tests-select'
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
# We run the full test suite with the GI reactor against an X virtual
# framebuffer server. This covers our integration with the version
# of Gtk packaged within our selected version of Linux above.
- python-version: '3.7'
- python-version: '3.8'
tox-env: 'alldeps-gtk-withcov-posix'
platform-deps: 'gtk-platform'
tox-wrapper: 'xvfb-run -a'
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Installation Requirements

To install Twisted, you need:

- Python 3.6/3.7/3.8/3.9
- Python 3.8/3.9/3.10/3.11/3.12

- `setuptools <https://pypi.python.org/pypi/setuptools>`_
(installed automatically if you use pip).
Expand Down
12 changes: 3 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ dynamic = [
description = "An asynchronous networking framework written in Python"
license = "MIT"
# When updating this value, make sure our CI matrix includes a matching minimum version.
requires-python = ">=3.7.1"
requires-python = ">=3.8.0"
authors = [
{ name = "Twisted Matrix Laboratories", email = "twisted-python@twistedmatrix.com" },
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -65,8 +64,7 @@ dev-release = [
"pydoctor ~= 23.4.0",
"sphinx-rtd-theme ~= 1.2",
"readthedocs-sphinx-ext ~= 2.2",
# We can move to v6 once we no longer need to support Python 3.7.
"sphinx >= 5, <7",
"sphinx >= 6, <7",
# This is due to cachecontrol not being compatible with urllib3>=2.0
# See https://github.com/ionrock/cachecontrol/issues/293
"urllib3 <2",
Expand Down Expand Up @@ -106,12 +104,8 @@ http2 = [
"priority >= 1.1.0, < 2.0",
]

contextvars = [
"contextvars >= 2.4, < 3; python_version < '3.7'",
]

all-non-platform = [
"twisted[test,tls,conch,serial,http2,contextvars]",
"twisted[test,tls,conch,serial,http2]",
]

macos-platform = [
Expand Down
43 changes: 0 additions & 43 deletions src/twisted/conch/test/test_filetransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from twisted.internet.testing import StringTransport
from twisted.protocols import loopback
from twisted.python import components
from twisted.python.compat import _PY37PLUS
from twisted.python.filepath import FilePath
from twisted.trial.unittest import TestCase

Expand Down Expand Up @@ -532,48 +531,6 @@ def _cbTestExtendedRequest(self, ignored):
self._emptyBuffers()
return self.assertFailure(d, NotImplementedError)

@defer.inlineCallbacks
@skipIf(_PY37PLUS, "Broken by PEP 479 and deprecated.")
def test_openDirectoryIterator(self):
"""
Check that the object returned by
L{filetransfer.FileTransferClient.openDirectory} can be used
as an iterator.
"""

# This function is a little more complicated than it would be
# normally, since we need to call _emptyBuffers() after
# creating any SSH-related Deferreds, but before waiting on
# them via yield.

d = self.client.openDirectory(b"")
self._emptyBuffers()
openDir = yield d

filenames = set()
try:
for f in openDir:
self._emptyBuffers()
(filename, _, fileattrs) = yield f
filenames.add(filename)
finally:
d = openDir.close()
self._emptyBuffers()
yield d

self._emptyBuffers()

self.assertEqual(
filenames,
{
b".testHiddenFile",
b"testDirectory",
b"testRemoveFile",
b"testRenameFile",
b"testfile1",
},
)

@defer.inlineCallbacks
def test_openDirectoryIteratorDeprecated(self):
"""
Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/11913.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for Python 3.7.
6 changes: 0 additions & 6 deletions src/twisted/python/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import os
import platform
import socket
import sys
import urllib.parse as urllib_parse
import warnings
from collections.abc import Sequence
Expand All @@ -43,11 +42,6 @@

from twisted.python.deprecate import deprecated, deprecatedModuleAttribute

if sys.version_info >= (3, 7, 0):
_PY37PLUS = True
else:
_PY37PLUS = False

if platform.python_implementation() == "PyPy":
_PYPY = True
else:
Expand Down
60 changes: 24 additions & 36 deletions src/twisted/web/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
from twisted.logger import Logger
from twisted.protocols import basic, policies
from twisted.python import log
from twisted.python.compat import _PY37PLUS, nativeString, networkString
from twisted.python.compat import nativeString, networkString
from twisted.python.components import proxyForInterface
from twisted.python.deprecate import deprecated
from twisted.python.failure import Failure
Expand Down Expand Up @@ -983,41 +983,29 @@ def requestReceived(self, command, path, version):
args.update(parse_qs(self.content.read(), 1))
elif key == mfd:
try:
if _PY37PLUS:
cgiArgs = cgi.parse_multipart(
self.content,
pdict,
encoding="utf8",
errors="surrogateescape",
)
else:
cgiArgs = cgi.parse_multipart(self.content, pdict)

if _PY37PLUS:
# The parse_multipart function on Python 3.7+
# decodes the header bytes as iso-8859-1 and
# decodes the body bytes as utf8 with
# surrogateescape -- we want bytes
self.args.update(
{
x.encode("iso-8859-1"): [
z.encode("utf8", "surrogateescape")
if isinstance(z, str)
else z
for z in y
]
for x, y in cgiArgs.items()
if isinstance(x, str)
}
)
else:
# The parse_multipart function on Python 3
# decodes the header bytes as iso-8859-1 and
# returns a str key -- we want bytes so encode
# it back
self.args.update(
{x.encode("iso-8859-1"): y for x, y in cgiArgs.items()}
)
cgiArgs = cgi.parse_multipart(
self.content,
pdict,
encoding="utf8",
errors="surrogateescape",
)

# The parse_multipart function on Python 3.7+
# decodes the header bytes as iso-8859-1 and
# decodes the body bytes as utf8 with
# surrogateescape -- we want bytes
self.args.update(
{
x.encode("iso-8859-1"): [
z.encode("utf8", "surrogateescape")
if isinstance(z, str)
else z
for z in y
]
for x, y in cgiArgs.items()
if isinstance(x, str)
}
)
except Exception as e:
# It was a bad request, or we got a signal.
self.channel._respondToBadRequestAndDisconnect()
Expand Down

0 comments on commit d05751f

Please sign in to comment.