Skip to content

Commit b5c7cf7

Browse files
committed
Drop Python 2
1 parent a48bcfb commit b5c7cf7

Some content is hidden

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

51 files changed

+315
-748
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
strategy:
1616
matrix:
1717
PYTHON:
18-
- {VERSION: "2.7", TOXENV: "py27", EXTRA_CFLAGS: ""}
1918
- {VERSION: "3.6", TOXENV: "py36", EXTRA_CFLAGS: ""}
2019
- {VERSION: "3.9", TOXENV: "py39", EXTRA_CFLAGS: "-DUSE_OSRANDOM_RNG_FOR_TESTING"}
2120
name: "Python ${{ matrix.PYTHON.VERSION }} on macOS"
@@ -58,7 +57,6 @@ jobs:
5857
- {ARCH: 'x86', WINDOWS: 'win32'}
5958
- {ARCH: 'x64', WINDOWS: 'win64'}
6059
PYTHON:
61-
- {VERSION: "2.7", TOXENV: "py27", MSVC_VERSION: "2010", CL_FLAGS: ""}
6260
- {VERSION: "3.6", TOXENV: "py36", MSVC_VERSION: "2019", CL_FLAGS: ""}
6361
- {VERSION: "3.7", TOXENV: "py37", MSVC_VERSION: "2019", CL_FLAGS: ""}
6462
- {VERSION: "3.8", TOXENV: "py38", MSVC_VERSION: "2019", CL_FLAGS: ""}
@@ -72,13 +70,6 @@ jobs:
7270
python-version: ${{ matrix.PYTHON.VERSION }}
7371
architecture: ${{ matrix.WINDOWS.ARCH }}
7472

75-
- name: Install MSVC for Python 2.7
76-
run: |
77-
Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile VCForPython27.msi
78-
Start-Process msiexec -Wait -ArgumentList @('/i', 'VCForPython27.msi', '/qn', 'ALLUSERS=1')
79-
Remove-Item VCForPython27.msi -Force
80-
shell: powershell
81-
if: matrix.PYTHON.VERSION == '2.7'
8273
- run: python -m pip install tox requests coverage
8374
- name: Download OpenSSL
8475
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.6", MSVC_VERSION: "2019"}
119114
- {VERSION: "3.7", MSVC_VERSION: "2019"}
120115
- {VERSION: "3.8", MSVC_VERSION: "2019"}
@@ -127,13 +122,6 @@ jobs:
127122
with:
128123
python-version: ${{ matrix.PYTHON.VERSION }}
129124
architecture: ${{ matrix.WINDOWS.ARCH }}
130-
- name: Install MSVC for Python 2.7
131-
run: |
132-
Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile VCForPython27.msi
133-
Start-Process msiexec -Wait -ArgumentList @('/i', 'VCForPython27.msi', '/qn', 'ALLUSERS=1')
134-
Remove-Item VCForPython27.msi -Force
135-
shell: powershell
136-
if: matrix.PYTHON.VERSION == '2.7'
137125
- run: pip install requests
138126
- name: Download OpenSSL
139127
run: |

.travis.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@ matrix:
2727
env: TOXENV=py39
2828
# Travis lists available Pythons (including PyPy) by arch and distro here:
2929
# https://docs.travis-ci.com/user/languages/python/#python-versions
30-
- python: pypy2.7-7.3.1
31-
env: TOXENV=pypy-nocoverage
3230
- python: pypy3.6-7.3.1
3331
env: TOXENV=pypy3-nocoverage
34-
- python: 2.7
35-
env: TOXENV=py27 OPENSSL=1.1.0l
36-
- python: 2.7
37-
env: TOXENV=py27-ssh OPENSSL=1.1.0l
3832
- python: 3.8
3933
env: TOXENV=py38 OPENSSL=1.1.0l
40-
- python: 2.7
41-
env: TOXENV=py27 OPENSSL=1.1.1h
4234
- python: 3.8
4335
env: TOXENV=py38 OPENSSL=1.1.1h
4436
- python: 3.8
@@ -54,18 +46,12 @@ matrix:
5446
- python: 3.8
5547
env: TOXENV=py38 LIBRESSL=3.2.2
5648

57-
- python: 2.7
58-
services: docker
59-
env: TOXENV=py27 DOCKER=pyca/cryptography-runner-centos8
6049
- python: 3.6
6150
services: docker
6251
env: TOXENV=py36 DOCKER=pyca/cryptography-runner-centos8
6352
- python: 3.6
6453
services: docker
6554
env: TOXENV=py36 OPENSSL_FORCE_FIPS_MODE=1 DOCKER=pyca/cryptography-runner-centos8-fips
66-
- python: 2.7
67-
services: docker
68-
env: TOXENV=py27 DOCKER=pyca/cryptography-runner-stretch
6955
- python: 3.7
7056
services: docker
7157
env: TOXENV=py37 DOCKER=pyca/cryptography-runner-buster
@@ -81,9 +67,6 @@ matrix:
8167
- python: 3.8
8268
services: docker
8369
env: TOXENV=py38 DOCKER=pyca/cryptography-runner-ubuntu-focal
84-
- python: 2.7
85-
services: docker
86-
env: TOXENV=py27 DOCKER=pyca/cryptography-runner-ubuntu-rolling
8770
- python: 3.8
8871
services: docker
8972
env: TOXENV=py38 DOCKER=pyca/cryptography-runner-ubuntu-rolling

.travis/upload_coverage.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set -x
55

66
if [ -n "${TOXENV}" ]; then
77
case "${TOXENV}" in
8-
pypy-nocoverage);;
98
pypy3-nocoverage);;
109
pep8);;
1110
py3pep8);;

.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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
"Operating System :: POSIX :: Linux",
7474
"Operating System :: Microsoft :: Windows",
7575
"Programming Language :: Python",
76-
"Programming Language :: Python :: 2",
77-
"Programming Language :: Python :: 2.7",
7876
"Programming Language :: Python :: 3",
7977
"Programming Language :: Python :: 3.6",
8078
"Programming Language :: Python :: 3.7",
@@ -87,11 +85,10 @@
8785
package_dir={"": "src"},
8886
packages=find_packages(where="src", exclude=["_cffi_src", "_cffi_src.*"]),
8987
include_package_data=True,
90-
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
91-
install_requires=["six >= 1.4.1"] + setup_requirements,
88+
python_requires=">=3.6",
89+
install_requires=setup_requirements,
9290
setup_requires=setup_requirements,
9391
extras_require={
94-
":python_version < '3'": ["enum34", "ipaddress"],
9592
"test": [
9693
"pytest>=3.6.0,!=3.9.0,!=3.9.1,!=3.9.2",
9794
"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 a "
38-
"future 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)