From 7c2f6d5272571c41b9224c59a3a4b71da6baf291 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 16 Apr 2025 11:41:13 +0100 Subject: [PATCH 1/2] Compensate for asyncio changes in Python 3.13.3/3.14 In https://github.com/python/cpython/commit/38a99568763604ccec5d5027f0658100ad76876f (backported to 3.13 as https://github.com/python/cpython/commit/7b0543ebe649aea11531e994289293f23f41064e), Python moved the responsibility for setting the task name from `asyncio.create_task` to the `Task` constructor. While `uvloop` itself is unaffected, this causes `test_set_task_name` to fail when run with `asyncio`. Compensate for that in this particular test. It's possible that `uvloop`'s behaviour should be changed to match `asyncio`'s depending on the Python version, but that seems like a more involved change. For now, this at least gets the tests passing again. Most of this analysis and patch were from Martin Hostettler in https://bugs.debian.org/1101258#24; I just tweaked the patch slightly to ensure it still passes on older Python versions. --- tests/test_base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_base.py b/tests/test_base.py index 86bbd1d0..feac44b8 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -576,9 +576,14 @@ def get_name(self): async def coro(): pass - factory = lambda loop, coro, **kwargs: MyTask( - coro, loop=loop, **kwargs - ) + def factory(loop, coro, **kwargs): + task = MyTask(coro, loop=loop, **kwargs) + # Python moved the responsibility to set the name to the Task + # class constructor, so MyTask.set_name is never called by + # Python's create_task. Compensate for that here. + if self.is_asyncio_loop() and "name" in kwargs: + task.set_name(kwargs["name"]) + return task self.assertIsNone(self.loop.get_task_factory()) task = self.loop.create_task(coro(), name="mytask") From 15ce4f63dc9d6ccba2e444b8d794f30c750b0bf6 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Thu, 17 Apr 2025 10:24:39 -0400 Subject: [PATCH 2/2] Don't use Cython beta This was for Cython 3.0 beta to test with Python 3.13, but it's now breaking our tests with Cython 3.1, while Cython 3.0 stable is out. --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed6accb9..b5bdc6f3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,8 +57,6 @@ jobs: - name: Install Python Deps if: steps.release.outputs.version == 0 - env: - PIP_PRE: ${{ matrix.python-version == '3.13' && '1' || '0' }} run: | pip install -e .[test,dev]