Skip to content

Commit bef2159

Browse files
committed
Drop support for Python 2
1 parent 522b004 commit bef2159

21 files changed

+40
-115
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ jobs:
1313
max-parallel: 5
1414
matrix:
1515
python-version:
16-
- 2.7
1716
- 3.6
1817
- 3.7
1918
- 3.8
20-
- pypy2
2119
- pypy3
2220

2321
steps:

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ other hand, the following are all very welcome:
7070
tox
7171
```
7272

73-
But note that: (1) this will print slightly misleading coverage
73+
But note that: (1) this might print slightly misleading coverage
7474
statistics, because it only shows coverage for individual python
75-
versions, and there are some lines that are only executed on python
76-
2 or only executed on python 3, and (2) the full test suite will
75+
versions, and there might be some lines that are only executed on some
76+
python versions or implementations, and (2) the full test suite will
7777
automatically get run when you submit a pull request, so you don't
7878
need to worry too much about tracking down a version of cpython 3.3
7979
or whatever just to run the tests.

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ library.
112112
It has a test suite with 100.0% coverage for both statements and
113113
branches.
114114

115-
Currently it supports Python 3 (testing on 3.5-3.8), Python 2.7, and PyPy.
115+
Currently it supports Python 3 (testing on 3.5-3.8) and PyPy 3.
116+
The last Python 2-compatible version was h11 0.11.x.
116117
(Originally it had a Cython wrapper for `http-parser
117118
<https://github.com/nodejs/http-parser>`_ and a beautiful nested state
118119
machine implemented with ``yield from`` to postprocess the output. But

bench/asv.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
// The Pythons you'd like to test against. If not provided, defaults
3838
// to the current version of Python used to run `asv`.
39-
"pythons": ["2.7", "3.5", "pypy"],
39+
"pythons": ["3.8", "pypy3"],
4040

4141
// The matrix of dependencies to test. Each key is the name of a
4242
// package (in PyPI) and the values are version numbers. An empty

docs/source/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ whatever. But h11 makes it much easier to implement something like
4444
Vital statistics
4545
----------------
4646

47-
* Requirements: Python 2.7 or Python 3.5+ (PyPy works great)
47+
* Requirements: Python 3.5+ (PyPy works great)
48+
49+
The last Python 2-compatible version was h11 0.11.x.
4850

4951
* Install: ``pip install h11``
5052

fuzz/afl-server.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99

1010
import h11
1111

12-
if sys.version_info[0] >= 3:
13-
in_file = sys.stdin.detach()
14-
else:
15-
in_file = sys.stdin
16-
1712

1813
def process_all(c):
1914
while True:
@@ -26,7 +21,7 @@ def process_all(c):
2621

2722
afl.init()
2823

29-
data = in_file.read()
24+
data = sys.stdin.detach().read()
3025

3126
# one big chunk
3227
server1 = h11.Connection(h11.SERVER)

h11/_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _body_framing(request_method, event):
109109
################################################################
110110

111111

112-
class Connection(object):
112+
class Connection:
113113
"""An object encapsulating the state of an HTTP connection.
114114
115115
Args:

h11/_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
request_target_re = re.compile(request_target.encode("ascii"))
2525

2626

27-
class _EventBundle(object):
27+
class _EventBundle:
2828
_fields = []
2929
_defaults = {}
3030

h11/_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def normalize_and_validate(headers, _parsed=False):
132132
raw_name = name
133133
name = name.lower()
134134
if name == b"content-length":
135-
lengths = set(length.strip() for length in value.split(b","))
135+
lengths = {length.strip() for length in value.split(b",")}
136136
if len(lengths) != 1:
137137
raise LocalProtocolError("conflicting Content-Length headers")
138138
value = lengths.pop()

h11/_readers.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ def _obsolete_line_fold(lines):
5454

5555
def _decode_header_lines(lines):
5656
for line in _obsolete_line_fold(lines):
57-
# _obsolete_line_fold yields either bytearray or bytes objects. On
58-
# Python 3, validate() takes either and returns matches as bytes. But
59-
# on Python 2, validate can return matches as bytearrays, so we have
60-
# to explicitly cast back.
61-
matches = validate(
62-
header_field_re, bytes(line), "illegal header line: {!r}", bytes(line)
63-
)
57+
matches = validate(header_field_re, line, "illegal header line: {!r}", line)
6458
yield (matches["field_name"], matches["field_value"])
6559

6660

@@ -127,7 +121,7 @@ def read_eof(self):
127121
chunk_header_re = re.compile(chunk_header.encode("ascii"))
128122

129123

130-
class ChunkedReader(object):
124+
class ChunkedReader:
131125
def __init__(self):
132126
self._bytes_in_chunk = 0
133127
# After reading a chunk, we have to throw away the trailing \r\n; if
@@ -163,9 +157,7 @@ def __call__(self, buf):
163157
chunk_header,
164158
)
165159
# XX FIXME: we discard chunk extensions. Does anyone care?
166-
# We convert to bytes because Python 2's `int()` function doesn't
167-
# work properly on bytearray objects.
168-
self._bytes_in_chunk = int(bytes(matches["chunk_size"]), base=16)
160+
self._bytes_in_chunk = int(matches["chunk_size"], base=16)
169161
if self._bytes_in_chunk == 0:
170162
self._reading_trailer = True
171163
return self(buf)
@@ -191,7 +183,7 @@ def read_eof(self):
191183
)
192184

193185

194-
class Http10Reader(object):
186+
class Http10Reader:
195187
def __call__(self, buf):
196188
data = buf.maybe_extract_at_most(999999999)
197189
if data is None:

0 commit comments

Comments
 (0)