Skip to content

Commit bb0cb39

Browse files
authored
Drop Python 3.6 support (#940)
1 parent eccdf61 commit bb0cb39

File tree

11 files changed

+11
-54
lines changed

11 files changed

+11
-54
lines changed

Diff for: .github/workflows/tests.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ jobs:
1717
# job.
1818
strategy:
1919
matrix:
20-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-rc.2"]
20+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-rc.2"]
2121
os: [ubuntu-latest, macos-latest, windows-latest]
2222
loop: [asyncio, uvloop]
2323
exclude:
24-
# uvloop does not support Python 3.6
25-
- loop: uvloop
26-
python-version: "3.6"
2724
# uvloop does not support windows
2825
- loop: uvloop
2926
os: windows-latest

Diff for: README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ of PostgreSQL server binary protocol for use with Python's ``asyncio``
1313
framework. You can read more about asyncpg in an introductory
1414
`blog post <http://magic.io/blog/asyncpg-1m-rows-from-postgres-to-python/>`_.
1515

16-
asyncpg requires Python 3.6 or later and is supported for PostgreSQL
16+
asyncpg requires Python 3.7 or later and is supported for PostgreSQL
1717
versions 9.5 to 14. Older PostgreSQL versions or other databases implementing
1818
the PostgreSQL protocol *may* work, but are not being actively tested.
1919

Diff for: asyncpg/compat.py

-10
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import asyncio
99
import pathlib
1010
import platform
11-
import sys
1211

1312

14-
PY_37 = sys.version_info >= (3, 7)
1513
SYSTEM = platform.uname().system
1614

1715

@@ -36,14 +34,6 @@ def get_pg_home_directory() -> pathlib.Path:
3634
return pathlib.Path.home()
3735

3836

39-
if PY_37:
40-
def current_asyncio_task(loop):
41-
return asyncio.current_task(loop)
42-
else:
43-
def current_asyncio_task(loop):
44-
return asyncio.Task.current_task(loop)
45-
46-
4737
async def wait_closed(stream):
4838
# Not all asyncio versions have StreamWriter.wait_closed().
4939
if hasattr(stream, 'wait_closed'):

Diff for: asyncpg/connect_utils.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ def _parse_hostlist(hostlist, port, *, unquote=False):
237237

238238

239239
def _parse_tls_version(tls_version):
240-
if not hasattr(ssl_module, 'TLSVersion'):
241-
raise ValueError(
242-
"TLSVersion is not supported in this version of Python"
243-
)
244240
if tls_version.startswith('SSL'):
245241
raise ValueError(
246242
f"Unsupported TLS version: {tls_version}"
@@ -573,11 +569,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
573569
ssl_min_protocol_version
574570
)
575571
else:
576-
try:
577-
ssl.minimum_version = _parse_tls_version('TLSv1.2')
578-
except ValueError:
579-
# Python 3.6 does not have ssl.TLSVersion
580-
pass
572+
ssl.minimum_version = _parse_tls_version('TLSv1.2')
581573

582574
if ssl_max_protocol_version is None:
583575
ssl_max_protocol_version = os.getenv('PGSSLMAXPROTOCOLVERSION')

Diff for: asyncpg/connection.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import warnings
2121
import weakref
2222

23-
from . import compat
2423
from . import connect_utils
2524
from . import cursor
2625
from . import exceptions
@@ -1468,7 +1467,7 @@ async def _cancel(self, waiter):
14681467
waiter.set_exception(ex)
14691468
finally:
14701469
self._cancellations.discard(
1471-
compat.current_asyncio_task(self._loop))
1470+
asyncio.current_task(self._loop))
14721471
if not waiter.done():
14731472
waiter.set_result(None)
14741473

Diff for: asyncpg/pool.py

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ def __new__(mcls, name, bases, dct, *, wrap=False):
4343

4444
return super().__new__(mcls, name, bases, dct)
4545

46-
def __init__(cls, name, bases, dct, *, wrap=False):
47-
# Needed for Python 3.5 to handle `wrap` class keyword argument.
48-
super().__init__(name, bases, dct)
49-
5046
@staticmethod
5147
def _wrap_connection_method(meth_name):
5248
def call_con_method(self, *args, **kwargs):

Diff for: asyncpg/protocol/scram.pyx

+2-9
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@ import base64
99
import hashlib
1010
import hmac
1111
import re
12+
import secrets
1213
import stringprep
1314
import unicodedata
1415

1516

16-
# try to import the secrets library from Python 3.6+ for the
17-
# cryptographic token generator for generating nonces as part of SCRAM
18-
# Otherwise fall back on os.urandom
19-
try:
20-
from secrets import token_bytes as generate_token_bytes
21-
except ImportError:
22-
from os import urandom as generate_token_bytes
23-
2417
@cython.final
2518
cdef class SCRAMAuthentication:
2619
"""Contains the protocol for generating and a SCRAM hashed password.
@@ -198,7 +191,7 @@ cdef class SCRAMAuthentication:
198191
cdef:
199192
bytes token
200193

201-
token = generate_token_bytes(num_bytes)
194+
token = secrets.token_bytes(num_bytes)
202195

203196
return base64.b64encode(token)
204197

Diff for: docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PostgreSQL and Python/asyncio. asyncpg is an efficient, clean implementation
1414
of PostgreSQL server binary protocol for use with Python's ``asyncio``
1515
framework.
1616

17-
**asyncpg** requires Python 3.6 or later and is supported for PostgreSQL
17+
**asyncpg** requires Python 3.7 or later and is supported for PostgreSQL
1818
versions 9.5 to 14. Older PostgreSQL versions or other databases implementing
1919
the PostgreSQL protocol *may* work, but are not being actively tested.
2020

Diff for: setup.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import sys
99

10-
if sys.version_info < (3, 6):
11-
raise RuntimeError('asyncpg requires Python 3.6 or greater')
10+
if sys.version_info < (3, 7):
11+
raise RuntimeError('asyncpg requires Python 3.7 or greater')
1212

1313
import os
1414
import os.path
@@ -30,7 +30,7 @@
3030
# Minimal dependencies required to test asyncpg.
3131
TEST_DEPENDENCIES = [
3232
'flake8~=5.0.4',
33-
'uvloop>=0.15.3; platform_system != "Windows" and python_version >= "3.7"',
33+
'uvloop>=0.15.3; platform_system != "Windows"',
3434
]
3535

3636
# Dependencies required to build documentation.
@@ -255,7 +255,6 @@ def finalize_options(self):
255255
'Operating System :: MacOS :: MacOS X',
256256
'Operating System :: Microsoft :: Windows',
257257
'Programming Language :: Python :: 3 :: Only',
258-
'Programming Language :: Python :: 3.6',
259258
'Programming Language :: Python :: 3.7',
260259
'Programming Language :: Python :: 3.8',
261260
'Programming Language :: Python :: 3.9',
@@ -264,7 +263,7 @@ def finalize_options(self):
264263
'Topic :: Database :: Front-Ends',
265264
],
266265
platforms=['macOS', 'POSIX', 'Windows'],
267-
python_requires='>=3.6.0',
266+
python_requires='>=3.7.0',
268267
zip_safe=False,
269268
author='MagicStack Inc',
270269
author_email='[email protected]',

Diff for: tests/test_connect.py

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import shutil
1515
import ssl
1616
import stat
17-
import sys
1817
import tempfile
1918
import textwrap
2019
import unittest
@@ -1466,10 +1465,6 @@ async def test_executemany_uvloop_ssl_issue_700(self):
14661465
finally:
14671466
await con.close()
14681467

1469-
@unittest.skipIf(
1470-
sys.version_info < (3, 7),
1471-
"Python < 3.7 doesn't have ssl.TLSVersion"
1472-
)
14731468
async def test_tls_version(self):
14741469
if self.cluster.get_pg_version() < (12, 0):
14751470
self.skipTest("PostgreSQL < 12 cannot set ssl protocol version")

Diff for: tests/test_pool.py

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import os
1111
import platform
1212
import random
13-
import sys
1413
import textwrap
1514
import time
1615
import unittest
@@ -741,7 +740,6 @@ async def test_pool_size_and_capacity(self):
741740
self.assertEqual(pool.get_size(), 3)
742741
self.assertEqual(pool.get_idle_size(), 0)
743742

744-
@unittest.skipIf(sys.version_info[:2] < (3, 6), 'no asyncgen support')
745743
async def test_pool_handles_transaction_exit_in_asyncgen_1(self):
746744
pool = await self.create_pool(database='postgres',
747745
min_size=1, max_size=1)
@@ -763,7 +761,6 @@ class MyException(Exception):
763761
async for _ in iterate(con): # noqa
764762
raise MyException()
765763

766-
@unittest.skipIf(sys.version_info[:2] < (3, 6), 'no asyncgen support')
767764
async def test_pool_handles_transaction_exit_in_asyncgen_2(self):
768765
pool = await self.create_pool(database='postgres',
769766
min_size=1, max_size=1)
@@ -788,7 +785,6 @@ class MyException(Exception):
788785

789786
del iterator
790787

791-
@unittest.skipIf(sys.version_info[:2] < (3, 6), 'no asyncgen support')
792788
async def test_pool_handles_asyncgen_finalization(self):
793789
pool = await self.create_pool(database='postgres',
794790
min_size=1, max_size=1)

0 commit comments

Comments
 (0)