From 20b9c35e9209aa1ce04a0f7d79d39acb28c3fa0a Mon Sep 17 00:00:00 2001 From: Andrey Semakin Date: Wed, 23 Jun 2021 15:02:17 +0500 Subject: [PATCH 1/3] Drop support for Python 3.5 --- .github/workflows/release.yml | 7 +------ .github/workflows/tests.yml | 10 ++-------- README.rst | 2 +- asyncpg/compat.py | 37 ----------------------------------- asyncpg/connection.py | 6 +++--- asyncpg/cursor.py | 2 -- asyncpg/pgproto | 2 +- docs/index.rst | 2 +- setup.py | 7 +++---- tests/test_copy.py | 4 ---- 10 files changed, 12 insertions(+), 67 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a578425..7ed44af1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,15 +72,10 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9] os: [ubuntu-20.04, macos-latest, windows-latest] arch: [x86_64] exclude: - # Python 3.5 is unable to properly - # find the recent VS tooling - # https://bugs.python.org/issue30389 - - os: windows-latest - python-version: 3.5 - os: windows-latest arch: aarch64 - os: macos-latest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 469af2b2..e55e282b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,14 +17,8 @@ jobs: # job. strategy: matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] - os: [ubuntu-latest, macos-latest, windows-latest] - exclude: - # Python 3.5 is unable to properly - # find the recent VS tooling - # https://bugs.python.org/issue30389 - - os: windows-latest - python-version: 3.5 + python-version: [3.6, 3.7, 3.8, 3.9] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} diff --git a/README.rst b/README.rst index 4ee68b4d..2f5da7a4 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ of PostgreSQL server binary protocol for use with Python's ``asyncio`` framework. You can read more about asyncpg in an introductory `blog post `_. -asyncpg requires Python 3.5 or later and is supported for PostgreSQL +asyncpg requires Python 3.6 or later and is supported for PostgreSQL versions 9.5 to 13. Older PostgreSQL versions or other databases implementing the PostgreSQL protocol *may* work, but are not being actively tested. diff --git a/asyncpg/compat.py b/asyncpg/compat.py index 6dbce3c9..348b8caa 100644 --- a/asyncpg/compat.py +++ b/asyncpg/compat.py @@ -6,52 +6,15 @@ import asyncio -import functools -import os import pathlib import platform import sys -PY_36 = sys.version_info >= (3, 6) PY_37 = sys.version_info >= (3, 7) SYSTEM = platform.uname().system -if sys.version_info < (3, 5, 2): - def aiter_compat(func): - @functools.wraps(func) - async def wrapper(self): - return func(self) - return wrapper -else: - def aiter_compat(func): - return func - - -if PY_36: - fspath = os.fspath -else: - def fspath(path): - fsp = getattr(path, '__fspath__', None) - if fsp is not None and callable(fsp): - path = fsp() - if not isinstance(path, (str, bytes)): - raise TypeError( - 'expected {}() to return str or bytes, not {}'.format( - fsp.__qualname__, type(path).__name__ - )) - return path - elif isinstance(path, (str, bytes)): - return path - else: - raise TypeError( - 'expected str, bytes or path-like object, not {}'.format( - type(path).__name__ - ) - ) - - if SYSTEM == 'Windows': import ctypes.wintypes diff --git a/asyncpg/connection.py b/asyncpg/connection.py index 043c6ddd..003526dd 100644 --- a/asyncpg/connection.py +++ b/asyncpg/connection.py @@ -10,6 +10,7 @@ import collections import collections.abc import itertools +import os import sys import time import traceback @@ -954,7 +955,7 @@ def _format_copy_opts(self, *, format=None, oids=None, freeze=None, async def _copy_out(self, copy_stmt, output, timeout): try: - path = compat.fspath(output) + path = os.fspath(output) except TypeError: # output is not a path-like object path = None @@ -993,7 +994,7 @@ async def _writer(data): async def _copy_in(self, copy_stmt, source, timeout): try: - path = compat.fspath(source) + path = os.fspath(source) except TypeError: # source is not a path-like object path = None @@ -1024,7 +1025,6 @@ async def _copy_in(self, copy_stmt, source, timeout): if f is not None: # Copying from a file-like object. class _Reader: - @compat.aiter_compat def __aiter__(self): return self diff --git a/asyncpg/cursor.py b/asyncpg/cursor.py index 978824c3..a9d3a6fa 100644 --- a/asyncpg/cursor.py +++ b/asyncpg/cursor.py @@ -48,7 +48,6 @@ def __init__( if state is not None: state.attach() - @compat.aiter_compat @connresource.guarded def __aiter__(self): prefetch = 50 if self._prefetch is None else self._prefetch @@ -206,7 +205,6 @@ def __init__( self._prefetch = prefetch self._timeout = timeout - @compat.aiter_compat @connresource.guarded def __aiter__(self): return self diff --git a/asyncpg/pgproto b/asyncpg/pgproto index 126bcd24..9a215f5b 160000 --- a/asyncpg/pgproto +++ b/asyncpg/pgproto @@ -1 +1 @@ -Subproject commit 126bcd24bd3c59d581613dae026e2721efbedf16 +Subproject commit 9a215f5bc592ced143d4fb636145f055fbf1eb36 diff --git a/docs/index.rst b/docs/index.rst index 77bf19f3..57031b03 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,7 +14,7 @@ PostgreSQL and Python/asyncio. asyncpg is an efficient, clean implementation of PostgreSQL server binary protocol for use with Python's ``asyncio`` framework. -**asyncpg** requires Python 3.5 or later and is supported for PostgreSQL +**asyncpg** requires Python 3.6 or later and is supported for PostgreSQL versions 9.5 to 13. Contents diff --git a/setup.py b/setup.py index b2fc8f33..606620cd 100644 --- a/setup.py +++ b/setup.py @@ -7,8 +7,8 @@ import sys -if sys.version_info < (3, 5): - raise RuntimeError('asyncpg requires Python 3.5 or greater') +if sys.version_info < (3, 6): + raise RuntimeError('asyncpg requires Python 3.6 or greater') import os import os.path @@ -259,7 +259,6 @@ def finalize_options(self): 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', @@ -268,7 +267,7 @@ def finalize_options(self): 'Topic :: Database :: Front-Ends', ], platforms=['macOS', 'POSIX', 'Windows'], - python_requires='>=3.5.0', + python_requires='>=3.6.0', zip_safe=False, author='MagicStack Inc', author_email='hello@magic.io', diff --git a/tests/test_copy.py b/tests/test_copy.py index dd01153f..441d0fa0 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -467,7 +467,6 @@ class _Source: def __init__(self): self.rowcount = 0 - @compat.aiter_compat def __aiter__(self): return self @@ -507,7 +506,6 @@ class _Source: def __init__(self): self.rowcount = 0 - @compat.aiter_compat def __aiter__(self): return self @@ -533,7 +531,6 @@ class _Source: def __init__(self): self.rowcount = 0 - @compat.aiter_compat def __aiter__(self): return self @@ -564,7 +561,6 @@ def __init__(self, loop): self.rowcount = 0 self.loop = loop - @compat.aiter_compat def __aiter__(self): return self From a141eb2a928674a143e0bfda9f4a53766d3a62f6 Mon Sep 17 00:00:00 2001 From: Andrey Semakin Date: Wed, 23 Jun 2021 15:04:57 +0500 Subject: [PATCH 2/3] Remove unused imports --- asyncpg/cursor.py | 1 - tests/test_copy.py | 1 - 2 files changed, 2 deletions(-) diff --git a/asyncpg/cursor.py b/asyncpg/cursor.py index a9d3a6fa..7ec159ba 100644 --- a/asyncpg/cursor.py +++ b/asyncpg/cursor.py @@ -7,7 +7,6 @@ import collections -from . import compat from . import connresource from . import exceptions diff --git a/tests/test_copy.py b/tests/test_copy.py index 441d0fa0..dcac96ac 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -13,7 +13,6 @@ import asyncpg from asyncpg import _testbase as tb -from asyncpg import compat class TestCopyFrom(tb.ConnectedTestCase): From 42ba8c05d980416bc81c1d41773553d1bc1207c1 Mon Sep 17 00:00:00 2001 From: Andrey Semakin Date: Wed, 23 Jun 2021 15:23:08 +0500 Subject: [PATCH 3/3] Update pgproto submodule to the correct commit --- asyncpg/pgproto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asyncpg/pgproto b/asyncpg/pgproto index 9a215f5b..719c7c76 160000 --- a/asyncpg/pgproto +++ b/asyncpg/pgproto @@ -1 +1 @@ -Subproject commit 9a215f5bc592ced143d4fb636145f055fbf1eb36 +Subproject commit 719c7c76ee92988f094c447bae18b47ab04a2185