Skip to content

Commit 488c93f

Browse files
committed
Drop Python 2
1 parent 1be144a commit 488c93f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+316
-739
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ jobs:
1818
- {VERSION: "3.9", TOXENV: "pep8,packaging,docs", COVERAGE: "false"}
1919
- {VERSION: "pypy2", TOXENV: "pypy-nocoverage", COVERAGE: "false"}
2020
- {VERSION: "pypy3", TOXENV: "pypy3-nocoverage", COVERAGE: "false"}
21-
- {VERSION: "2.7", TOXENV: "py27", OPENSSL: {TYPE: "openssl", VERSION: "1.1.0l"}}
22-
- {VERSION: "2.7", TOXENV: "py27-ssh", OPENSSL: {TYPE: "openssl", VERSION: "1.1.0l"}}
2321
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.0l"}}
24-
- {VERSION: "2.7", TOXENV: "py27", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1h"}}
2522
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1h"}}
2623
- {VERSION: "3.9", TOXENV: "py39-ssh", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1h"}}
2724
- {VERSION: "3.9", TOXENV: "py39", OPENSSL: {TYPE: "openssl", VERSION: "1.1.1h", CONFIG_FLAGS: "no-engine no-rc2 no-srtp no-ct"}}
@@ -86,16 +83,13 @@ jobs:
8683
strategy:
8784
matrix:
8885
IMAGE:
89-
- {IMAGE: "pyca/cryptography-runner-centos8", TOXENV: "py27"}
9086
- {IMAGE: "pyca/cryptography-runner-centos8", TOXENV: "py36"}
9187
- {IMAGE: "pyca/cryptography-runner-centos8-fips", TOXENV: "py36", ENV: "OPENSSL_FORCE_FIPS_MODE=1"}
92-
- {IMAGE: "pyca/cryptography-runner-stretch", TOXENV: "py27"}
9388
- {IMAGE: "pyca/cryptography-runner-buster", TOXENV: "py37"}
9489
- {IMAGE: "pyca/cryptography-runner-bullseye", TOXENV: "py38"}
9590
- {IMAGE: "pyca/cryptography-runner-sid", TOXENV: "py39"}
9691
- {IMAGE: "pyca/cryptography-runner-ubuntu-bionic", TOXENV: "py36"}
9792
- {IMAGE: "pyca/cryptography-runner-ubuntu-focal", TOXENV: "py38"}
98-
- {IMAGE: "pyca/cryptography-runner-ubuntu-rolling", TOXENV: "py27"}
9993
- {IMAGE: "pyca/cryptography-runner-ubuntu-rolling", TOXENV: "py38"}
10094
- {IMAGE: "pyca/cryptography-runner-ubuntu-rolling", TOXENV: "py38-randomorder"}
10195
- {IMAGE: "pyca/cryptography-runner-fedora", TOXENV: "py39"}
@@ -120,7 +114,6 @@ jobs:
120114
strategy:
121115
matrix:
122116
PYTHON:
123-
- {VERSION: "2.7", TOXENV: "py27", EXTRA_CFLAGS: ""}
124117
- {VERSION: "3.6", TOXENV: "py36", EXTRA_CFLAGS: ""}
125118
- {VERSION: "3.9", TOXENV: "py39", EXTRA_CFLAGS: "-DUSE_OSRANDOM_RNG_FOR_TESTING"}
126119
name: "Python ${{ matrix.PYTHON.VERSION }} on macOS"
@@ -162,7 +155,6 @@ jobs:
162155
- {ARCH: 'x86', WINDOWS: 'win32'}
163156
- {ARCH: 'x64', WINDOWS: 'win64'}
164157
PYTHON:
165-
- {VERSION: "2.7", TOXENV: "py27", MSVC_VERSION: "2010", CL_FLAGS: ""}
166158
- {VERSION: "3.6", TOXENV: "py36", MSVC_VERSION: "2019", CL_FLAGS: ""}
167159
- {VERSION: "3.7", TOXENV: "py37", MSVC_VERSION: "2019", CL_FLAGS: ""}
168160
- {VERSION: "3.8", TOXENV: "py38", MSVC_VERSION: "2019", CL_FLAGS: ""}
@@ -176,13 +168,6 @@ jobs:
176168
python-version: ${{ matrix.PYTHON.VERSION }}
177169
architecture: ${{ matrix.WINDOWS.ARCH }}
178170

179-
- name: Install MSVC for Python 2.7
180-
run: |
181-
Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile VCForPython27.msi
182-
Start-Process msiexec -Wait -ArgumentList @('/i', 'VCForPython27.msi', '/qn', 'ALLUSERS=1')
183-
Remove-Item VCForPython27.msi -Force
184-
shell: powershell
185-
if: matrix.PYTHON.VERSION == '2.7'
186171
- run: python -m pip install tox requests coverage
187172
- name: Download OpenSSL
188173
run: |

.github/workflows/wheel-builder.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
container: ${{ matrix.MANYLINUX.CONTAINER }}
1212
strategy:
1313
matrix:
14-
PYTHON: ["cp27-cp27m", "cp27-cp27mu", "cp36-cp36m"]
14+
PYTHON: ["cp36-cp36m"]
1515
MANYLINUX:
1616
- NAME: manylinux1_x86_64
1717
CONTAINER: "pyca/cryptography-manylinux1:x86_64"
@@ -57,10 +57,6 @@ jobs:
5757
strategy:
5858
matrix:
5959
PYTHON:
60-
- VERSION: '2.7'
61-
ABI_VERSION: '2.7'
62-
DOWNLOAD_URL: 'https://www.python.org/ftp/python/2.7.17/python-2.7.17-macosx10.9.pkg'
63-
BIN_PATH: '/Library/Frameworks/Python.framework/Versions/2.7/bin/python'
6460
- VERSION: '3.8'
6561
ABI_VERSION: '3.6'
6662
DOWNLOAD_URL: 'https://www.python.org/ftp/python/3.8.2/python-3.8.2-macosx10.9.pkg'
@@ -114,7 +110,6 @@ jobs:
114110
- {ARCH: 'x86', WINDOWS: 'win32'}
115111
- {ARCH: 'x64', WINDOWS: 'win64'}
116112
PYTHON:
117-
- {VERSION: "2.7", MSVC_VERSION: "2010"}
118113
- {VERSION: "3.8", MSVC_VERSION: "2019", "USE_ABI3": "true", "ABI_VERSION": "cp36"}
119114
name: "${{ matrix.PYTHON.VERSION }} ${{ matrix.WINDOWS.WINDOWS }} ${{ matrix.PYTHON.ABI_VERSION }}"
120115
steps:
@@ -124,13 +119,6 @@ jobs:
124119
with:
125120
python-version: ${{ matrix.PYTHON.VERSION }}
126121
architecture: ${{ matrix.WINDOWS.ARCH }}
127-
- name: Install MSVC for Python 2.7
128-
run: |
129-
Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile VCForPython27.msi
130-
Start-Process msiexec -Wait -ArgumentList @('/i', 'VCForPython27.msi', '/qn', 'ALLUSERS=1')
131-
Remove-Item VCForPython27.msi -Force
132-
shell: powershell
133-
if: matrix.PYTHON.VERSION == '2.7'
134122
- run: pip install requests
135123
- name: Download OpenSSL
136124
run: |

.zuul.d/jobs.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
vars:
2626
tox_envlist: py36
2727

28-
- job:
29-
name: pyca-cryptography-centos-8-py27-arm64
30-
parent: pyca-cryptography-base
31-
nodeset: centos-8-arm64
32-
vars:
33-
tox_envlist: py27
34-
3528
- job:
3629
name: pyca-cryptography-build-wheel
3730
abstract: true
@@ -57,12 +50,8 @@
5750
- platform: manylinux1_x86_64
5851
image: pyca/cryptography-manylinux1:x86_64
5952
pythons:
60-
- cp27-cp27m
61-
- cp27-cp27mu
6253
- cp36-cp36m
6354
- platform: manylinux2010_x86_64
6455
image: pyca/cryptography-manylinux2010:x86_64
6556
pythons:
66-
- cp27-cp27m
67-
- cp27-cp27mu
6857
- cp36-cp36m

.zuul.d/project.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
- pyca-cryptography-ubuntu-focal-py38-arm64
77
- pyca-cryptography-ubuntu-bionic-py36-arm64
88
- pyca-cryptography-centos-8-py36-arm64
9-
- pyca-cryptography-centos-8-py27-arm64
109
release:
1110
jobs:
1211
- pyca-cryptography-build-wheel-arm64

docs/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ You can install ``cryptography`` with ``pip``:
1010
Supported platforms
1111
-------------------
1212

13-
Currently we test ``cryptography`` on Python 2.7, 3.6+,
14-
PyPy 7.3.1, and PyPy3 7.3.1 on these operating systems.
13+
Currently we test ``cryptography`` on Python 3.6+ and PyPy3 7.3.1 on these
14+
operating systems.
1515

1616
* x86-64 CentOS 7.x
1717
* x86-64 & AArch64 CentOS 8.x
@@ -45,9 +45,9 @@ just run
4545
If you prefer to compile it yourself you'll need to have OpenSSL installed.
4646
You can compile OpenSSL yourself as well or use `a binary distribution`_.
4747
Be sure to download the proper version for your architecture and Python
48-
(VC2010 works for Python 2.7 while VC2015 is required for 3.6 and above).
49-
Wherever you place your copy of OpenSSL you'll need to set the ``LIB`` and ``INCLUDE``
50-
environment variables to include the proper locations. For example:
48+
(VC2015 is required for 3.6 and above). Wherever you place your copy of OpenSSL
49+
you'll need to set the ``LIB`` and ``INCLUDE`` environment variables to include
50+
the proper locations. For example:
5151

5252
.. code-block:: console
5353

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ build-backend = "setuptools.build_meta"
1111

1212
[tool.black]
1313
line-length = 79
14-
target-version = ["py27"]
14+
target-version = ["py36"]

setup.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
about = {}
2424
with open(os.path.join(src_dir, "cryptography", "__about__.py")) as f:
25-
exec (f.read(), about)
25+
exec(f.read(), about)
2626

2727

2828
# `setup_requirements` must be kept in sync with `pyproject.toml`
@@ -63,8 +63,6 @@
6363
"Operating System :: POSIX :: Linux",
6464
"Operating System :: Microsoft :: Windows",
6565
"Programming Language :: Python",
66-
"Programming Language :: Python :: 2",
67-
"Programming Language :: Python :: 2.7",
6866
"Programming Language :: Python :: 3",
6967
"Programming Language :: Python :: 3.6",
7068
"Programming Language :: Python :: 3.7",
@@ -79,13 +77,10 @@
7977
where="src", exclude=["_cffi_src", "_cffi_src.*"]
8078
),
8179
include_package_data=True,
82-
python_requires=(
83-
">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*"
84-
),
85-
install_requires=["six >= 1.4.1"] + setup_requirements,
80+
python_requires=(">=3.6"),
81+
install_requires=setup_requirements,
8682
setup_requires=setup_requirements,
8783
extras_require={
88-
":python_version < '3'": ["enum34", "ipaddress"],
8984
"test": [
9085
"pytest>=3.6.0,!=3.9.0,!=3.9.1,!=3.9.2",
9186
"pretend",

src/cryptography/__init__.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
from __future__ import absolute_import, division, print_function
66

7-
import sys
8-
import warnings
9-
107
from cryptography.__about__ import (
118
__author__,
129
__copyright__,
@@ -17,7 +14,6 @@
1714
__uri__,
1815
__version__,
1916
)
20-
from cryptography.utils import CryptographyDeprecationWarning
2117

2218

2319
__all__ = [
@@ -30,12 +26,3 @@
3026
"__license__",
3127
"__copyright__",
3228
]
33-
34-
if sys.version_info[0] == 2:
35-
warnings.warn(
36-
"Python 2 is no longer supported by the Python core team. Support for "
37-
"it is now deprecated in cryptography, and will be removed in the "
38-
"next release.",
39-
CryptographyDeprecationWarning,
40-
stacklevel=2,
41-
)

src/cryptography/fernet.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import struct
1111
import time
1212

13-
import six
14-
1513
from cryptography import utils
1614
from cryptography.exceptions import InvalidSignature
1715
from cryptography.hazmat.backends import _get_backend
@@ -97,7 +95,7 @@ def _get_unverified_token_data(token):
9795
except (TypeError, binascii.Error):
9896
raise InvalidToken
9997

100-
if not data or six.indexbytes(data, 0) != 0x80:
98+
if not data or data[0] != 0x80:
10199
raise InvalidToken
102100

103101
try:

src/cryptography/hazmat/_der.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from __future__ import absolute_import, division, print_function
66

7-
import six
8-
97
from cryptography.utils import int_from_bytes, int_to_bytes
108

119

@@ -53,7 +51,7 @@ def check_empty(self):
5351
def read_byte(self):
5452
if len(self.data) < 1:
5553
raise ValueError("Invalid DER input: insufficient data")
56-
ret = six.indexbytes(self.data, 0)
54+
ret = self.data[0]
5755
self.data = self.data[1:]
5856
return ret
5957

@@ -111,20 +109,20 @@ def read_single_element(self, expected_tag):
111109
return self.read_element(expected_tag)
112110

113111
def read_optional_element(self, expected_tag):
114-
if len(self.data) > 0 and six.indexbytes(self.data, 0) == expected_tag:
112+
if len(self.data) > 0 and self.data[0] == expected_tag:
115113
return self.read_element(expected_tag)
116114
return None
117115

118116
def as_integer(self):
119117
if len(self.data) == 0:
120118
raise ValueError("Invalid DER input: empty integer contents")
121-
first = six.indexbytes(self.data, 0)
119+
first = self.data[0]
122120
if first & 0x80 == 0x80:
123121
raise ValueError("Negative DER integers are not supported")
124122
# The first 9 bits must not all be zero or all be ones. Otherwise, the
125123
# encoding should have been one byte shorter.
126124
if len(self.data) > 1:
127-
second = six.indexbytes(self.data, 1)
125+
second = self.data[1]
128126
if first == 0 and second & 0x80 == 0:
129127
raise ValueError(
130128
"Invalid DER input: integer not minimally-encoded"
@@ -133,7 +131,7 @@ def as_integer(self):
133131

134132

135133
def encode_der_integer(x):
136-
if not isinstance(x, six.integer_types):
134+
if not isinstance(x, int):
137135
raise ValueError("Value must be an integer")
138136
if x < 0:
139137
raise ValueError("Negative integers are not supported")
@@ -145,12 +143,12 @@ def encode_der(tag, *children):
145143
length = 0
146144
for child in children:
147145
length += len(child)
148-
chunks = [six.int2byte(tag)]
146+
chunks = [bytes([tag])]
149147
if length < 0x80:
150-
chunks.append(six.int2byte(length))
148+
chunks.append(bytes([length]))
151149
else:
152150
length_bytes = int_to_bytes(length)
153-
chunks.append(six.int2byte(0x80 | len(length_bytes)))
151+
chunks.append(bytes([0x80 | len(length_bytes)]))
154152
chunks.append(length_bytes)
155153
chunks.extend(children)
156154
return b"".join(chunks)

0 commit comments

Comments
 (0)