]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: drop Python 3.7 support
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 1 Oct 2023 02:25:05 +0000 (04:25 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 3 Oct 2023 12:58:33 +0000 (14:58 +0200)
Also drop from the test grid PostgreSQL 10, now unsupported.

30 files changed:
.github/workflows/3rd-party-tests.yml
.github/workflows/packages-bin.yml
.github/workflows/tests.yml
docs/basic/install.rst
psycopg/psycopg/_compat.py
psycopg/psycopg/_struct.py
psycopg/psycopg/abc.py
psycopg/psycopg/copy.py
psycopg/psycopg/pq/abc.py
psycopg/psycopg/rows.py
psycopg/psycopg/types/array.py
psycopg/psycopg/version.py
psycopg/setup.cfg
psycopg_c/psycopg_c/_compat.py [deleted file]
psycopg_c/psycopg_c/version.py
psycopg_c/setup.cfg
psycopg_pool/psycopg_pool/_compat.py
psycopg_pool/psycopg_pool/pool_async.py
psycopg_pool/psycopg_pool/version.py
psycopg_pool/setup.cfg
tests/README.rst
tests/conftest.py
tests/crdb/test_connection_async.py
tests/crdb/test_cursor_async.py
tests/pool/test_null_pool_async.py
tests/pool/test_pool_async.py
tests/pool/test_sched_async.py
tests/test_concurrency_async.py
tests/test_transaction_async.py
tests/types/test_array.py

index 22e3e06d412ae246e7b88eb9ee8c69b6eae7d348..0058e431b6b29f8065725b3974497690c1410093 100644 (file)
@@ -26,7 +26,7 @@ jobs:
       matrix:
         python-version:
           - "3.11"
-          - "3.7"
+          - "3.8"
         sqlalchemy_label:
           # what version of sqlalchemy to download is defined in the "include" section below,
           # in the variable pip_sqlalchemy
index 123c75cb110ac70422b90532553311caf2b755d5..975fe4c5a5f80f17dc1161d5129609082fcb3acb 100644 (file)
@@ -19,7 +19,7 @@ jobs:
       fail-fast: false
       matrix:
         arch: [x86_64, i686, ppc64le, aarch64]
-        pyver: [cp37, cp38, cp39, cp310, cp311, cp312]
+        pyver: [cp38, cp39, cp310, cp311, cp312]
         platform: [manylinux, musllinux]
 
     steps:
@@ -101,7 +101,7 @@ jobs:
       matrix:
         # These archs require an Apple M1 runner: [arm64, universal2]
         arch: [x86_64]
-        pyver: [cp37, cp38, cp39, cp310, cp311, cp312]
+        pyver: [cp38, cp39, cp310, cp311, cp312]
 
     steps:
       - uses: actions/checkout@v3
@@ -144,7 +144,7 @@ jobs:
       matrix:
         # Might want to add win32, untested at the moment.
         arch: [win_amd64]
-        pyver: [cp37, cp38, cp39, cp310, cp311, cp312]
+        pyver: [cp38, cp39, cp310, cp311, cp312]
 
     steps:
       - uses: actions/checkout@v3
index c89ff1f2466cf6453bc45f5191ecea03fb761deb..690c9e98e5295e678c1ae2688d61437ade5056ab 100644 (file)
@@ -26,19 +26,17 @@ jobs:
       matrix:
         include:
           # Test different combinations of Python, Postgres, libpq.
-          - {impl: python, python: "3.7", postgres: "postgres:11", libpq: newest}
-          - {impl: python, python: "3.8", postgres: "postgres:10"}
+          - {impl: python, python: "3.8", postgres: "postgres:11", libpq: newest}
           - {impl: python, python: "3.9", postgres: "postgres:13"}
           - {impl: python, python: "3.10", postgres: "postgres:14"}
           - {impl: python, python: "3.11", postgres: "postgres:15", libpq: master}
           - {impl: python, python: "3.12", postgres: "postgres:16", libpq: oldest}
 
-          - {impl: c, python: "3.7", postgres: "postgres:16", libpq: newest}
-          - {impl: c, python: "3.8", postgres: "postgres:14", libpq: master}
-          - {impl: c, python: "3.9", postgres: "postgres:15"}
-          - {impl: c, python: "3.10", postgres: "postgres:13"}
+          - {impl: c, python: "3.8", postgres: "postgres:16", libpq: newest}
+          - {impl: c, python: "3.9", postgres: "postgres:14", libpq: master}
+          - {impl: c, python: "3.10", postgres: "postgres:15"}
           - {impl: c, python: "3.11", postgres: "postgres:12", libpq: oldest}
-          - {impl: c, python: "3.12", postgres: "postgres:10", libpq: newest}
+          - {impl: c, python: "3.12", postgres: "postgres:11", libpq: newest}
 
           - {impl: python, python: "3.9", ext: dns, postgres: "postgres:14"}
           - {impl: python, python: "3.9", ext: postgis, postgres: "postgis/postgis"}
@@ -46,7 +44,7 @@ jobs:
           - {impl: c, python: "3.11", ext: numpy, postgres: "postgres:15"}
 
           # Test with minimum dependencies versions
-          - {impl: c, python: "3.7", ext: min, postgres: "postgres:15"}
+          - {impl: c, python: "3.8", ext: min, postgres: "postgres:15"}
 
     env:
       PSYCOPG_IMPL: ${{ matrix.impl }}
@@ -119,13 +117,11 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - {impl: python, python: "3.7"}
           - {impl: python, python: "3.8"}
           - {impl: python, python: "3.9"}
           - {impl: python, python: "3.10"}
           - {impl: python, python: "3.11"}
           - {impl: python, python: "3.12"}
-          - {impl: c, python: "3.7"}
           - {impl: c, python: "3.8"}
           - {impl: c, python: "3.9"}
           - {impl: c, python: "3.10"}
@@ -176,13 +172,11 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - {impl: python, python: "3.7"}
           - {impl: python, python: "3.8"}
           - {impl: python, python: "3.9"}
           - {impl: python, python: "3.10"}
           - {impl: python, python: "3.11"}
           - {impl: python, python: "3.12"}
-          - {impl: c, python: "3.7"}
           - {impl: c, python: "3.8"}
           - {impl: c, python: "3.9"}
           - {impl: c, python: "3.10"}
index 120c08f4ac46ec428682ea321274b99c7691f121..d0613f13ae802df9f37e192582d88bfe4d541571 100644 (file)
@@ -19,9 +19,10 @@ Supported systems
 
 The Psycopg version documented here has *official and tested* support for:
 
-- Python: from version 3.7 to 3.12
+- Python: from version 3.8 to 3.12
 
   - Python 3.6 supported before Psycopg 3.1
+  - Python 3.7 supported before Psycopg 3.2
 
 - PostgreSQL: from version 10 to 16
 - OS: Linux, macOS, Windows
index 5c8e87cdbe62065f114a470d1e09a8f2e1ff6314..d496817ad009bf8d141cff6fcd40a30a1b6cfa22 100644 (file)
@@ -5,38 +5,6 @@ compatibility functions for different Python versions
 # Copyright (C) 2021 The Psycopg Team
 
 import sys
-import asyncio
-from typing import Any, Awaitable, Generator, Optional, Sequence, Union, TypeVar
-
-# NOTE: TypeAlias cannot be exported by this module, as pyright special-cases it.
-# For this raisin it must be imported directly from typing_extension where used.
-# See https://github.com/microsoft/pyright/issues/4197
-from typing_extensions import TypeAlias
-
-if sys.version_info >= (3, 8):
-    from typing import Protocol
-else:
-    from typing_extensions import Protocol
-
-T = TypeVar("T")
-FutureT: TypeAlias = Union["asyncio.Future[T]", Generator[Any, None, T], Awaitable[T]]
-
-if sys.version_info >= (3, 8):
-    create_task = asyncio.create_task
-    from math import prod
-
-else:
-
-    def create_task(
-        coro: FutureT[T], name: Optional[str] = None
-    ) -> "asyncio.Future[T]":
-        return asyncio.create_task(coro)
-
-    from functools import reduce
-
-    def prod(seq: Sequence[int]) -> int:
-        return reduce(int.__mul__, seq, 1)
-
 
 if sys.version_info >= (3, 9):
     from zoneinfo import ZoneInfo
@@ -59,21 +27,12 @@ if sys.version_info >= (3, 11):
 else:
     from typing_extensions import LiteralString, assert_type
 
-if sys.version_info < (3, 8):
-    import importlib_metadata as metadata
-else:
-    from importlib import metadata
-
 __all__ = [
     "Counter",
     "Deque",
     "LiteralString",
-    "Protocol",
     "TypeGuard",
     "ZoneInfo",
     "assert_type",
     "cache",
-    "create_task",
-    "prod",
-    "metadata",
 ]
index 28a6084475ac0919e8f21506404b9c0e552a7c90..bce427c808d1737b5844dd8c3c7bede9f38c6cbd 100644 (file)
@@ -5,12 +5,11 @@ Utility functions to deal with binary structs.
 # Copyright (C) 2020 The Psycopg Team
 
 import struct
-from typing import Callable, cast, Optional, Tuple
+from typing import Callable, cast, Optional, Protocol, Tuple
 from typing_extensions import TypeAlias
 
 from .abc import Buffer
 from . import errors as e
-from ._compat import Protocol
 
 PackInt: TypeAlias = Callable[[int], bytes]
 UnpackInt: TypeAlias = Callable[[Buffer], Tuple[int]]
index 0cf1a7511c8877fba777b83bfb8e1bd255390336..0ee2037ac5d5c7805c33ff30c3b7e4de4aff19af 100644 (file)
@@ -5,13 +5,13 @@ Protocol objects representing different implementations of the same classes.
 # Copyright (C) 2020 The Psycopg Team
 
 from typing import Any, Callable, Generator, Mapping
-from typing import List, Optional, Sequence, Tuple, TypeVar, Union
+from typing import List, Optional, Protocol, Sequence, Tuple, TypeVar, Union
 from typing import TYPE_CHECKING
 from typing_extensions import TypeAlias
 
 from . import pq
 from ._enums import PyFormat as PyFormat
-from ._compat import Protocol, LiteralString
+from ._compat import LiteralString
 
 if TYPE_CHECKING:
     from . import sql
index de1270c55163adaf7f13fb5e2e9deeae30c08426..d52e9b93d3dc03705b0c38f4afc9e830645c7345 100644 (file)
@@ -18,7 +18,6 @@ from . import pq
 from . import adapt
 from . import errors as e
 from .abc import Buffer, ConnectionType, PQGen, Transformer
-from ._compat import create_task
 from .pq.misc import connection_summary
 from ._cmodule import _psycopg
 from ._encodings import pgconn_encoding
@@ -634,7 +633,7 @@ class AsyncQueuedLibpqWriter(AsyncLibpqWriter):
 
     async def write(self, data: Buffer) -> None:
         if not self._worker:
-            self._worker = create_task(self.worker())
+            self._worker = asyncio.create_task(self.worker())
 
         if len(data) <= MAX_BUFFER_SIZE:
             # Most used path: we don't need to split the buffer in smaller
index e8ece59f6a0e4bc71b2661be8e53f1c9a0d2efdc..3a76d56c086bb72ce1b5d0902a2d1f23a6217968 100644 (file)
@@ -4,12 +4,11 @@ Protocol objects to represent objects exposed by different pq implementations.
 
 # Copyright (C) 2020 The Psycopg Team
 
-from typing import Any, Callable, List, Optional, Sequence, Tuple
+from typing import Any, Callable, List, Optional, Protocol, Sequence, Tuple
 from typing import Union, TYPE_CHECKING
 from typing_extensions import TypeAlias
 
 from ._enums import Format, Trace
-from .._compat import Protocol
 
 if TYPE_CHECKING:
     from .misc import PGnotify, ConninfoOption, PGresAttDesc
index 2b240f7fb6accf47724ad9a41fc18622a405e31c..5655a43dd802b84f76b18a51658cb7568afa1fb7 100644 (file)
@@ -6,13 +6,12 @@ psycopg row factories
 
 import functools
 from typing import Any, Callable, Dict, List, Optional, NamedTuple, NoReturn
-from typing import TYPE_CHECKING, Sequence, Tuple, Type, TypeVar
+from typing import TYPE_CHECKING, Protocol, Sequence, Tuple, Type, TypeVar
 from collections import namedtuple
 from typing_extensions import TypeAlias
 
 from . import pq
 from . import errors as e
-from ._compat import Protocol
 from ._encodings import _as_python_identifier
 
 if TYPE_CHECKING:
index e75725aa7cb444f2c0734b3cdb8dccc5f5e5f218..3a8b1328e04f2094eea4683e4fe93c1815ebc90b 100644 (file)
@@ -6,6 +6,7 @@ Adapters for arrays
 
 import re
 import struct
+from math import prod
 from typing import Any, cast, Callable, List, Optional, Pattern, Set, Tuple, Type
 
 from .. import pq
@@ -14,7 +15,7 @@ from .. import postgres
 from ..abc import AdaptContext, Buffer, Dumper, DumperKey, NoneType, Loader, Transformer
 from ..adapt import RecursiveDumper, RecursiveLoader, PyFormat
 from .._oids import TEXT_OID, INVALID_OID, TEXT_ARRAY_OID
-from .._compat import cache, prod
+from .._compat import cache
 from .._struct import pack_len, unpack_len
 from .._cmodule import _psycopg
 from .._typeinfo import TypeInfo
index 3b2e075276b8b87ba131c9c5f7ee3665a19183e1..b6c68c2b9676e4f4df7563e5425fa0f2c67c5b6a 100644 (file)
@@ -4,7 +4,7 @@ psycopg distribution version file.
 
 # Copyright (C) 2020 The Psycopg Team
 
-from ._compat import metadata
+from importlib import metadata
 
 try:
     __version__ = metadata.version("psycopg")
index 9af8c578390c86f7ff62dae1e6db8eec46270729..bdffb04f7ad0417c8363a13f501707347c035014 100644 (file)
@@ -33,7 +33,6 @@ classifiers =
     Operating System :: Microsoft :: Windows
     Operating System :: POSIX
     Programming Language :: Python :: 3
-    Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
     Programming Language :: Python :: 3.9
     Programming Language :: Python :: 3.10
@@ -49,14 +48,13 @@ long_description_content_type = text/x-rst
 license_files = LICENSE.txt
 
 [options]
-python_requires = >= 3.7
+python_requires = >= 3.8
 packages = find:
 zip_safe = False
 install_requires =
     backports.zoneinfo >= 0.2.0; python_version < "3.9"
     typing-extensions >= 4.2
     tzdata; sys_platform == "win32"
-    importlib-metadata >= 1.4, < 6.8; python_version < "3.8"
 
 [options.extras_require]
 c =
diff --git a/psycopg_c/psycopg_c/_compat.py b/psycopg_c/psycopg_c/_compat.py
deleted file mode 100644 (file)
index 16992cb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-"""
-compatibility functions for different Python versions
-"""
-
-# Copyright (C) 2021 The Psycopg Team
-
-import sys
-
-if sys.version_info < (3, 8):
-    import importlib_metadata as metadata
-else:
-    from importlib import metadata
-
-
-__all__ = ["metadata"]
index 1da39db1f4e2f399327597447c4333b722069726..47bdfbce37fb7a84bbcdb3ac0e80f20632b146f5 100644 (file)
@@ -4,7 +4,7 @@ psycopg-c distribution version file.
 
 # Copyright (C) 2020 The Psycopg Team
 
-from ._compat import metadata
+from importlib import metadata
 
 try:
     __version__ = metadata.version("psycopg-c")
index fde807e94a867efcd03e6ec29bfe1277bcb59d9e..730596f4d8ee91b5dba47551ddab222ef1523fae 100644 (file)
@@ -23,7 +23,6 @@ classifiers =
     Operating System :: Microsoft :: Windows
     Operating System :: POSIX
     Programming Language :: Python :: 3
-    Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
     Programming Language :: Python :: 3.9
     Programming Language :: Python :: 3.10
@@ -39,11 +38,9 @@ long_description_content_type = text/x-rst
 license_files = LICENSE.txt
 
 [options]
-python_requires = >= 3.7
+python_requires = >= 3.8
 packages = find:
 zip_safe = False
-install_requires =
-    importlib-metadata >= 1.4, < 6.8; python_version < "3.8"
 
 [options.package_data]
 # NOTE: do not include .pyx files: they shouldn't be in the sdist
index 2ddbcb158a1d824dbde550ecdc25ff193dedd395..c3e27f02b85f80231ca9a1d6637cd1239b1646ec 100644 (file)
@@ -5,44 +5,18 @@ compatibility functions for different Python versions
 # Copyright (C) 2021 The Psycopg Team
 
 import sys
-import asyncio
-from typing import Any, Awaitable, Generator, Optional, Union, Type, TypeVar
-from typing_extensions import TypeAlias
+from typing import Type
 
 import psycopg.errors as e
 
-T = TypeVar("T")
-FutureT: TypeAlias = Union["asyncio.Future[T]", Generator[Any, None, T], Awaitable[T]]
-
-if sys.version_info >= (3, 8):
-    create_task = asyncio.create_task
-    Task = asyncio.Task
-
-else:
-
-    def create_task(
-        coro: FutureT[T], name: Optional[str] = None
-    ) -> "asyncio.Future[T]":
-        return asyncio.create_task(coro)
-
-    Task = asyncio.Future
-
 if sys.version_info >= (3, 9):
     from collections import Counter, deque as Deque
 else:
     from typing import Counter, Deque
 
-if sys.version_info < (3, 8):
-    import importlib_metadata as metadata
-else:
-    from importlib import metadata
-
 __all__ = [
     "Counter",
     "Deque",
-    "Task",
-    "create_task",
-    "metadata",
 ]
 
 # Workaround for psycopg < 3.0.8.
index 9ee8e85541d42662bdf97edf52a439ca730fa6e6..76a2cf489e5ddf4644cf34bd3cd19c46fcd2bb85 100644 (file)
@@ -12,6 +12,7 @@ from types import TracebackType
 from typing import Any, AsyncIterator, Awaitable, Callable, cast, Generic
 from typing import Dict, List, Optional, overload, Sequence, Type, TypeVar, Union
 from typing_extensions import TypeAlias
+from asyncio import create_task, Task
 from weakref import ref
 from contextlib import asynccontextmanager
 
@@ -23,7 +24,7 @@ from psycopg.rows import TupleRow
 from .base import ConnectionAttempt, BasePool
 from .sched import AsyncScheduler
 from .errors import PoolClosed, PoolTimeout, TooManyRequests
-from ._compat import Task, create_task, Deque
+from ._compat import Deque
 
 logger = logging.getLogger("psycopg.pool")
 
index 628f16a1a8a94e2bc45fbf72f82941f5da82b677..765e0360564a8bf7f9d960c0592f4ee5a44ee63c 100644 (file)
@@ -4,7 +4,7 @@ psycopg pool version file.
 
 # Copyright (C) 2021 The Psycopg Team
 
-from ._compat import metadata
+from importlib import metadata
 
 try:
     __version__ = metadata.version("psycopg-pool")
index 43378bd4910b0ade6a0fd4ba0240c2e93f3bc232..f08727f456f46aba6b5008dcb44c20f584e40bd0 100644 (file)
@@ -27,7 +27,6 @@ classifiers =
     Operating System :: Microsoft :: Windows
     Operating System :: POSIX
     Programming Language :: Python :: 3
-    Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
     Programming Language :: Python :: 3.9
     Programming Language :: Python :: 3.10
@@ -43,12 +42,11 @@ long_description_content_type = text/x-rst
 license_files = LICENSE.txt
 
 [options]
-python_requires = >= 3.7
+python_requires = >= 3.8
 packages = find:
 zip_safe = False
 install_requires =
     typing-extensions >= 3.10
-    importlib-metadata >= 1.4, < 6.8; python_version < "3.8"
 
 [options.package_data]
 psycopg_pool = py.typed
index 63c72382a9f54fb062c2bccdd13d744bec390b85..b99be83222b50365af36607c5b437c7f8837788a 100644 (file)
@@ -74,7 +74,7 @@ a set of env vars working for your setup::
 
     $ docker run -ti --rm --volume `pwd`:/src --workdir /src \
       -e PSYCOPG_TEST_DSN -e PGHOST=172.17.0.1 -e PGUSER=`whoami` \
-      python:3.7 bash
+      python:3.8 bash
 
     # pip install -e "./psycopg[test]" ./psycopg_pool ./psycopg_c
     # pytest
index e674f6e765f7f2258e8b78eab3e3d495c573f4c2..ab3295448b1e18e5d7bfb8882088612f036aaaf4 100644 (file)
@@ -69,7 +69,7 @@ def pytest_sessionstart(session):
 
 
 asyncio_options: Dict[str, Any] = {}
-if sys.platform == "win32" and sys.version_info >= (3, 8):
+if sys.platform == "win32":
     asyncio_options["policy"] = asyncio.WindowsSelectorEventLoopPolicy()
 
 
index 9cd73ddd7926a0da45baa4ea9a6cd0bf5d373525..9b224e41f26430853cca6b32062747b0b6ef955a 100644 (file)
@@ -4,7 +4,6 @@ import asyncio
 import psycopg.crdb
 from psycopg import errors as e
 from psycopg.crdb import AsyncCrdbConnection
-from psycopg._compat import create_task
 
 import pytest
 
@@ -74,7 +73,7 @@ async def test_identify_closure(aconn_cls, dsn):
                 await asyncio.sleep(0.2)
                 await conn2.execute("cancel session %s", [session_id])
 
-            t = create_task(closer())
+            t = asyncio.create_task(closer())
             t0 = time.time()
             try:
                 with pytest.raises(psycopg.OperationalError):
index 2472c37f20a97bc2ba591eef67a8f42c3ac2ef4f..c643a40c3c138f0614b3b25e2c46c072fa57b49a 100644 (file)
@@ -6,7 +6,6 @@ from asyncio.queues import Queue
 import pytest
 from psycopg import pq, errors as e
 from psycopg.rows import namedtuple_row
-from psycopg._compat import create_task
 
 from .test_cursor import testfeed
 
@@ -36,7 +35,7 @@ async def test_changefeed(aconn_cls, dsn, aconn, testfeed, fmt_out):
         except Exception as ex:
             q.put_nowait(ex)
 
-    t = create_task(worker())
+    t = asyncio.create_task(worker())
 
     cur = aconn.cursor()
     await cur.execute(f"insert into {testfeed} (data) values ('hello') returning id")
index 47b0c88209b53715893fae18cba6cfd78a93ad8e..55708e50aa0e39dec21cc9e0d75f9de1068e7757 100644 (file)
@@ -2,6 +2,7 @@ import asyncio
 import logging
 from time import time
 from typing import Any, Dict, List, Tuple
+from asyncio import create_task
 
 import pytest
 from packaging.version import parse as ver  # noqa: F401  # used in skipif
@@ -9,7 +10,7 @@ from packaging.version import parse as ver  # noqa: F401  # used in skipif
 import psycopg
 from psycopg.pq import TransactionStatus
 from psycopg.rows import class_row, Row, TupleRow
-from psycopg._compat import assert_type, create_task
+from psycopg._compat import assert_type
 from .test_pool_async import delay_connection, ensure_waiting
 
 pytestmark = [pytest.mark.anyio]
@@ -901,7 +902,6 @@ async def test_stats_connect(dsn, proxy, monkeypatch):
         assert 200 <= stats["connections_ms"] < 300
 
 
-@pytest.mark.skipif("sys.version_info < (3, 8)", reason="asyncio bug")
 async def test_cancellation_in_queue(dsn):
     # https://github.com/psycopg/psycopg/issues/509
 
@@ -949,7 +949,6 @@ async def test_cancellation_in_queue(dsn):
             pytest.fail("no client got in the queue")
 
         [task.cancel() for task in reversed(tasks)]
-        # Python 3.7 hangs on this statement, instead of timing out or returning
         await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), 1.0)
 
         stats = p.get_stats()
index 31861df91570ff7e6d0ada9febd0c556723de957..0726f35c727dcd559a9c279d3afeae35e0f8df93 100644 (file)
@@ -2,13 +2,14 @@ import asyncio
 import logging
 from time import time
 from typing import Any, Dict, List, Tuple
+from asyncio import create_task
 
 import pytest
 
 import psycopg
 from psycopg.pq import TransactionStatus
 from psycopg.rows import class_row, Row, TupleRow
-from psycopg._compat import assert_type, create_task, Counter
+from psycopg._compat import assert_type, Counter
 
 try:
     import psycopg_pool as pool
@@ -1263,7 +1264,6 @@ async def test_debug_deadlock(dsn):
         logger.setLevel(old_level)
 
 
-@pytest.mark.skipif("sys.version_info < (3, 8)", reason="asyncio bug")
 async def test_cancellation_in_queue(dsn):
     # https://github.com/psycopg/psycopg/issues/509
 
@@ -1309,7 +1309,6 @@ async def test_cancellation_in_queue(dsn):
             pytest.fail("no client got in the queue")
 
         [task.cancel() for task in reversed(tasks)]
-        # Python 3.7 hangs on this statement, instead of timing out or returning
         await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), 1.0)
 
         stats = p.get_stats()
index 82eb44276b29a232bc8cb38ae1d8292abc75c3d3..45c94a5eb41171f125cfb0c82fb41c83dd9e619a 100644 (file)
@@ -1,12 +1,11 @@
 import asyncio
 import logging
 from time import time
+from asyncio import create_task
 from functools import partial
 
 import pytest
 
-from psycopg._compat import create_task
-
 try:
     from psycopg_pool.sched import AsyncScheduler
 except ImportError:
index 017bbd79e419ff050f3fc3e38f09fd8d04c7e716..db97a4bf08d370234df879c85ac1db8cc8d726b2 100644 (file)
@@ -4,6 +4,7 @@ import signal
 import asyncio
 import threading
 import subprocess as sp
+from asyncio import create_task
 from asyncio.queues import Queue
 from typing import List, Tuple
 
@@ -11,7 +12,6 @@ import pytest
 
 import psycopg
 from psycopg import errors as e
-from psycopg._compat import create_task
 
 
 @pytest.mark.slow
index 921ea5a1458676f13ec4962c6f6a76608a576e3e..abe5bf06315051e11d3b1e019b3718d064ced806 100644 (file)
@@ -5,7 +5,6 @@ import pytest
 
 from psycopg import Rollback
 from psycopg import errors as e
-from psycopg._compat import create_task
 
 from .test_transaction import in_transaction, insert_row, inserted, get_exc_info
 from .test_transaction import ExpectedException, crdb_skip_external_observer
@@ -729,11 +728,11 @@ async def test_concurrency(aconn, what):
             assert "transaction commit" in str(ex.value)
 
     # Start a first transaction in a task
-    t1 = create_task(worker(unlock=evs[0], wait_on=evs[1]))
+    t1 = asyncio.create_task(worker(unlock=evs[0], wait_on=evs[1]))
     await evs[0].wait()
 
     # Start a nested transaction in a task
-    t2 = create_task(worker(unlock=evs[1], wait_on=evs[2]))
+    t2 = asyncio.create_task(worker(unlock=evs[1], wait_on=evs[2]))
 
     # Terminate the first transaction before the second does
     await asyncio.gather(t1)
index 1f8c0f0de109a8f21da94c3b6210171128998cd0..f9fb85ccb8d6e8dd6d1737fb1cfd4e3538a4f402 100644 (file)
@@ -1,4 +1,5 @@
 import gc
+from math import prod
 from typing import List, Any
 from decimal import Decimal
 
@@ -9,7 +10,6 @@ from psycopg import pq
 from psycopg import sql
 from psycopg.adapt import PyFormat, Transformer, Dumper
 from psycopg.types import TypeInfo
-from psycopg._compat import prod
 from psycopg.postgres import types as builtins
 from psycopg.types.array import register_array