From e5d1240babff6db6297e0d92f174446de19cf76d Mon Sep 17 00:00:00 2001
From: Kumar Aditya
Date: Sun, 18 May 2025 23:02:42 +0530
Subject: [PATCH 1/3] remove use of deprecated policy API from tests (#10851)
---
CHANGES/10851.bugfix.rst | 1 +
CHANGES/10851.contrib.rst | 2 ++
aiohttp/pytest_plugin.py | 27 ++++++++++++++-------------
tests/conftest.py | 12 ++++--------
tests/test_connector.py | 2 +-
tests/test_loop.py | 4 ++--
tests/test_proxy_functional.py | 2 +-
7 files changed, 25 insertions(+), 25 deletions(-)
create mode 100644 CHANGES/10851.bugfix.rst
create mode 100644 CHANGES/10851.contrib.rst
diff --git a/CHANGES/10851.bugfix.rst b/CHANGES/10851.bugfix.rst
new file mode 100644
index 00000000000..9c47cc95905
--- /dev/null
+++ b/CHANGES/10851.bugfix.rst
@@ -0,0 +1 @@
+Fixed pytest plugin to not use deprecated :py:mod:`asyncio` policy APIs.
diff --git a/CHANGES/10851.contrib.rst b/CHANGES/10851.contrib.rst
new file mode 100644
index 00000000000..623f96bc227
--- /dev/null
+++ b/CHANGES/10851.contrib.rst
@@ -0,0 +1,2 @@
+Updated tests to avoid using deprecated :py:mod:`asyncio` policy APIs and
+make it compatible with Python 3.14.
diff --git a/aiohttp/pytest_plugin.py b/aiohttp/pytest_plugin.py
index 9d11231c6f4..bce4cda68ce 100644
--- a/aiohttp/pytest_plugin.py
+++ b/aiohttp/pytest_plugin.py
@@ -224,9 +224,13 @@ def pytest_pyfunc_call(pyfuncitem): # type: ignore[no-untyped-def]
"""Run coroutines in an event loop instead of a normal function call."""
fast = pyfuncitem.config.getoption("--aiohttp-fast")
if inspect.iscoroutinefunction(pyfuncitem.function):
- existing_loop = pyfuncitem.funcargs.get(
- "proactor_loop"
- ) or pyfuncitem.funcargs.get("loop", None)
+ existing_loop = (
+ pyfuncitem.funcargs.get("proactor_loop")
+ or pyfuncitem.funcargs.get("selector_loop")
+ or pyfuncitem.funcargs.get("uvloop_loop")
+ or pyfuncitem.funcargs.get("loop", None)
+ )
+
with _runtime_warning_context():
with _passthrough_loop_context(existing_loop, fast=fast) as _loop:
testargs = {
@@ -243,11 +247,11 @@ def pytest_generate_tests(metafunc): # type: ignore[no-untyped-def]
return
loops = metafunc.config.option.aiohttp_loop
- avail_factories: Dict[str, Type[asyncio.AbstractEventLoopPolicy]]
- avail_factories = {"pyloop": asyncio.DefaultEventLoopPolicy}
+ avail_factories: dict[str, Callable[[], asyncio.AbstractEventLoop]]
+ avail_factories = {"pyloop": asyncio.new_event_loop}
if uvloop is not None:
- avail_factories["uvloop"] = uvloop.EventLoopPolicy
+ avail_factories["uvloop"] = uvloop.new_event_loop
if loops == "all":
loops = "pyloop,uvloop?"
@@ -272,14 +276,12 @@ def pytest_generate_tests(metafunc): # type: ignore[no-untyped-def]
@pytest.fixture
def loop(
- loop_factory: Callable[[], asyncio.AbstractEventLoopPolicy],
+ loop_factory: Callable[[], asyncio.AbstractEventLoop],
fast: bool,
loop_debug: bool,
) -> Iterator[asyncio.AbstractEventLoop]:
"""Return an instance of the event loop."""
- policy = loop_factory()
- asyncio.set_event_loop_policy(policy)
- with loop_context(fast=fast) as _loop:
+ with loop_context(loop_factory, fast=fast) as _loop:
if loop_debug:
_loop.set_debug(True)
asyncio.set_event_loop(_loop)
@@ -288,10 +290,9 @@ def loop(
@pytest.fixture
def proactor_loop() -> Iterator[asyncio.AbstractEventLoop]:
- policy = asyncio.WindowsProactorEventLoopPolicy() # type: ignore[attr-defined]
- asyncio.set_event_loop_policy(policy)
+ factory = asyncio.ProactorEventLoop # type: ignore[attr-defined]
- with loop_context(policy.new_event_loop) as _loop:
+ with loop_context(factory) as _loop:
asyncio.set_event_loop(_loop)
yield _loop
diff --git a/tests/conftest.py b/tests/conftest.py
index 573d992e464..97b8c960a69 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -233,20 +233,16 @@ def assert_sock_fits(sock_path: str) -> None:
@pytest.fixture
def selector_loop() -> Iterator[asyncio.AbstractEventLoop]:
- policy = asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]
- asyncio.set_event_loop_policy(policy)
-
- with loop_context(policy.new_event_loop) as _loop:
+ factory = asyncio.SelectorEventLoop
+ with loop_context(factory) as _loop:
asyncio.set_event_loop(_loop)
yield _loop
@pytest.fixture
def uvloop_loop() -> Iterator[asyncio.AbstractEventLoop]:
- policy = uvloop.EventLoopPolicy()
- asyncio.set_event_loop_policy(policy)
-
- with loop_context(policy.new_event_loop) as _loop:
+ factory = uvloop.new_event_loop
+ with loop_context(factory) as _loop:
asyncio.set_event_loop(_loop)
yield _loop
diff --git a/tests/test_connector.py b/tests/test_connector.py
index c4019df3cdf..1315dbcd485 100644
--- a/tests/test_connector.py
+++ b/tests/test_connector.py
@@ -124,7 +124,7 @@ def create_mocked_conn(
try:
loop = asyncio.get_running_loop()
except RuntimeError:
- loop = asyncio.get_event_loop_policy().get_event_loop()
+ loop = asyncio.get_event_loop()
f = loop.create_future()
proto: mock.Mock = mock.create_autospec(
diff --git a/tests/test_loop.py b/tests/test_loop.py
index f71a5e6a140..eec0057748a 100644
--- a/tests/test_loop.py
+++ b/tests/test_loop.py
@@ -37,7 +37,7 @@ async def test_on_startup_hook(self) -> None:
def test_default_loop(loop: asyncio.AbstractEventLoop) -> None:
- assert asyncio.get_event_loop_policy().get_event_loop() is loop
+ assert asyncio.get_event_loop() is loop
def test_setup_loop_non_main_thread() -> None:
@@ -46,7 +46,7 @@ def test_setup_loop_non_main_thread() -> None:
def target() -> None:
try:
with loop_context() as loop:
- assert asyncio.get_event_loop_policy().get_event_loop() is loop
+ assert asyncio.get_event_loop() is loop
loop.run_until_complete(test_subprocess_co(loop))
except Exception as exc:
nonlocal child_exc
diff --git a/tests/test_proxy_functional.py b/tests/test_proxy_functional.py
index b29b255a758..404b7ed1ae4 100644
--- a/tests/test_proxy_functional.py
+++ b/tests/test_proxy_functional.py
@@ -241,7 +241,6 @@ async def test_https_proxy_unsupported_tls_in_tls(
await asyncio.sleep(0.1)
-@pytest.mark.usefixtures("uvloop_loop")
@pytest.mark.skipif(
platform.system() == "Windows" or sys.implementation.name != "cpython",
reason="uvloop is not supported on Windows and non-CPython implementations",
@@ -253,6 +252,7 @@ async def test_https_proxy_unsupported_tls_in_tls(
async def test_uvloop_secure_https_proxy(
client_ssl_ctx: ssl.SSLContext,
secure_proxy_url: URL,
+ uvloop_loop: asyncio.AbstractEventLoop,
) -> None:
"""Ensure HTTPS sites are accessible through a secure proxy without warning when using uvloop."""
conn = aiohttp.TCPConnector()
From 5633bedac1c520ff249880801959897b30c35ead Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 19 May 2025 10:55:33 +0000
Subject: [PATCH 2/3] Bump cython from 3.0.12 to 3.1.1 (#10875)
Bumps [cython](https://github.com/cython/cython) from 3.0.12 to 3.1.1.
Release notes
Sourced from cython's
releases.
3.1.1
No release notes provided.
3.1.0-1
No release notes provided.
3.1.0
No release notes provided.
3.1.0rc2
No release notes provided.
3.1.0rc1
No release notes provided.
3.1.0b1
No release notes provided.
3.1.0a1
3.1.0 alpha 1 (2024-11-08)
Features added
-
Support for freethreading builds of CPython 3.13 was added.
It comes with a new directive freethreading_compatible=True
to mark modules as
free-threading compatible (Py_mod_gil).
https://github.com/cython/cython/issues?q=label%3A"nogil+CPython"
Patches by Lysandros Nikolaou and Nathan Goldbaum. (Github issue
:issue:6162)
-
Support for monitoring Cython modules via sys.monitoring
in CPython 3.13+ was added.
For coverage reporting, this needs to be disabled with
-DCYTHON_USE_SYS_MONITORING=0
as long as coverage.py does not support
sys.monitoring for coverage plugins.
(Github issue :issue:6144)
-
Many issues with the Limited C-API were resolved.
It is now sufficient to define the macro Py_LIMITED_API to
activate the support.
https://github.com/cython/cython/issues?q=label%3A%22limited+api%22
-
Support for GraalPython was improved (but is still incomplete).
-
Several issues with the gdb support were resolved.
Patches by Kent Slaney. (Github issues :issue:5955,
:issue:5948)
-
typing.Union[SomeType, None] and SomeType |
None are now understood and mean
the same as typing.Optional[SomeType], allowing
None in type checks.
(Github issue :issue:6254)
-
cython.const[] and cython.volatile[] are
now available as type modifiers in Python code.
... (truncated)
Changelog
Sourced from cython's
changelog.
3.1.1 (2025-05-19)
Bugs fixed
-
A reference leak in the async delegation code was fixed.
(Github issues :issue:6850, :issue:6878)
-
Conditional if-else expressions mixing Python and C (numeric) types
could end up
inferring an overly tight result type, thus leading to unexpected type
conversions,
runtime exceptions on assignment, or incorrect "temporary
assignment" compile errors.
(Github issue :issue:6854)
-
Some Limited API issues were resolved.
(Github issue :issue:6862)
-
Large C long long values could be truncated when passed
into PyPy.
(Github issue :issue:6890)
-
callable() incorrectly reported False in
PyPy for classes with metaclasses.
Patch by Anatolii Aniskovych. (Github issue
:issue:6892)
-
The signature of fused functions was no longer introspectable in
Cython 3.1.0.
(Github issue :issue:6855)
-
Coroutines could generate invalid C with line tracing enabled.
(Github issue :issue:6865)
-
Code using complex() could generate invalid C code
missing type declarations.
(Github issue :issue:6860)
-
Code using e.g. list[int | None] outside of
variable/argument annotations failed to compile.
(Github issue :issue:6856)
-
Code using ctuples in a const context could generate
invalid C.
(Github issue :issue:6864)
-
Accessing special methods on cpdef enums failed to compile.
-
Some C compiler warnings were resolved.
Patches by Daniel Larraz. (Github issues :issue:6876,
:issue:3172, :issue:6873,
:issue:6877)
-
Re-establish support for PyPy 3.8.
(Github issue :issue:6867)
3.1.0 (2025-05-08)
... (truncated)
Commits
aeadbbe
Prepare release of Cython 3.1.1.
9532c33
Update changelog.
e7baa59
Use PyCallable_Check() instead of type slots for callable() in PyPy (GH-6894)
279377d
Fix race in dict getter (GH-6849)
987891e
Update changelog.
edac547
Avoid calling "PyLong_FromUnsignedLongLong()" in PyPy.
8e107e9
Document CYTHON_USE_SYS_MONITORING (GH-6886)
56ab917
CI: Fix PyPy3.8 build (GH-6889)
0ab0e32
Update trace/profile test config for Py3.12, which at least partially
works.
c4adc2d
CI: Also disable "twine" usage on "Py*t-dev"
versions.
- Additional commits viewable in compare
view
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
requirements/constraints.txt | 2 +-
requirements/cython.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/requirements/constraints.txt b/requirements/constraints.txt
index 54d906e9d26..a43f6bba709 100644
--- a/requirements/constraints.txt
+++ b/requirements/constraints.txt
@@ -60,7 +60,7 @@ cryptography==44.0.3
# via
# pyjwt
# trustme
-cython==3.0.12
+cython==3.1.1
# via -r requirements/cython.in
distlib==0.3.9
# via virtualenv
diff --git a/requirements/cython.txt b/requirements/cython.txt
index 8686651881b..1dd3cc00fc4 100644
--- a/requirements/cython.txt
+++ b/requirements/cython.txt
@@ -4,7 +4,7 @@
#
# pip-compile --allow-unsafe --output-file=requirements/cython.txt --resolver=backtracking --strip-extras requirements/cython.in
#
-cython==3.0.12
+cython==3.1.1
# via -r requirements/cython.in
multidict==6.4.3
# via -r requirements/multidict.in
From c5405bc27f1b97ffcdb065a0b487d495ca301af7 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 19 May 2025 11:12:38 +0000
Subject: [PATCH 3/3] Bump cryptography from 44.0.3 to 45.0.2 (#10876)
Bumps [cryptography](https://github.com/pyca/cryptography) from 44.0.3
to 45.0.2.
Changelog
Sourced from cryptography's
changelog.
45.0.2 - 2025-05-17
* Fixed using ``mypy`` with ``cryptography`` on older versions of
Python.
.. _v45-0-1:
45.0.1 - 2025-05-17
- Updated Windows, macOS, and Linux wheels to be compiled with OpenSSL
3.5.0.
.. _v45-0-0:
45.0.0 - 2025-05-17 (YANKED)
* Support for Python 3.7 is deprecated and will be removed in the next
``cryptography`` release.
* Updated the minimum supported Rust version (MSRV) to 1.74.0, from
1.65.0.
* Added support for serialization of PKCS#12 Java truststores in
:func:`~cryptography.hazmat.primitives.serialization.pkcs12.serialize_java_truststore`
* Added
:meth:`~cryptography.hazmat.primitives.kdf.argon2.Argon2id.derive_phc_encoded`
and
:meth:`~cryptography.hazmat.primitives.kdf.argon2.Argon2id.verify_phc_encoded`
methods
to support password hashing in the PHC string format
* Added support for PKCS7 decryption and encryption using AES-256 as the
content algorithm, in addition to AES-128.
* **BACKWARDS INCOMPATIBLE:** Made SSH private key loading more
consistent with
other private key loading:
:func:`~cryptography.hazmat.primitives.serialization.load_ssh_private_key`
now raises a ``TypeError`` if the key is unencrypted but a password is
provided (previously no exception was raised), and raises a
``TypeError`` if
the key is encrypted but no password is provided (previously a
``ValueError``
was raised).
* We significantly refactored how private key loading (
:func:`~cryptography.hazmat.primitives.serialization.load_pem_private_key`
and
:func:`~cryptography.hazmat.primitives.serialization.load_der_private_key`)
works. This is intended to be backwards compatible for all well-formed
keys,
therefore if you discover a key that now raises an exception, please
file a
bug with instructions for reproducing.
* Added ``unsafe_skip_rsa_key_validation`` keyword-argument to
:func:`~cryptography.hazmat.primitives.serialization.load_ssh_private_key`.
* Added :class:`~cryptography.hazmat.primitives.hashes.XOFHash` to
support
repeated :meth:`~cryptography.hazmat.primitives.hashes.XOFHash.squeeze`
operations on extendable output functions.
* Added
:meth:`~cryptography.x509.ocsp.OCSPResponseBuilder.add_response_by_hash`
method to allow creating OCSP responses using certificate hash values
rather
than full certificates.
</tr></table>
... (truncated)
Commits
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
requirements/constraints.txt | 2 +-
requirements/dev.txt | 2 +-
requirements/lint.txt | 2 +-
requirements/test.txt | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/requirements/constraints.txt b/requirements/constraints.txt
index a43f6bba709..9a90feebd30 100644
--- a/requirements/constraints.txt
+++ b/requirements/constraints.txt
@@ -56,7 +56,7 @@ coverage==7.8.0
# via
# -r requirements/test.in
# pytest-cov
-cryptography==44.0.3
+cryptography==45.0.2
# via
# pyjwt
# trustme
diff --git a/requirements/dev.txt b/requirements/dev.txt
index 802bec8ab15..365e27d8b40 100644
--- a/requirements/dev.txt
+++ b/requirements/dev.txt
@@ -56,7 +56,7 @@ coverage==7.8.0
# via
# -r requirements/test.in
# pytest-cov
-cryptography==44.0.3
+cryptography==45.0.2
# via
# pyjwt
# trustme
diff --git a/requirements/lint.txt b/requirements/lint.txt
index 3a6603a6b72..2c75e2c7505 100644
--- a/requirements/lint.txt
+++ b/requirements/lint.txt
@@ -21,7 +21,7 @@ cfgv==3.4.0
# via pre-commit
click==8.1.8
# via slotscheck
-cryptography==44.0.3
+cryptography==45.0.2
# via trustme
distlib==0.3.9
# via virtualenv
diff --git a/requirements/test.txt b/requirements/test.txt
index f94e6071307..83780809c8a 100644
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -29,7 +29,7 @@ coverage==7.8.0
# via
# -r requirements/test.in
# pytest-cov
-cryptography==44.0.3
+cryptography==45.0.2
# via trustme
exceptiongroup==1.3.0
# via pytest