The patch below fixes the Python 3.15 event-loop failures in qasync, the "FEFE.E" in tests/test_qeventloop.py. It does not change the "...Killed" in tests/test_qthreadexec.py from the original report, so the full package build still stops there.
Python 3.15's asyncio selector transports pass context= when they register a reader or writer. qasync's _QEventLoop._add_reader() and _add_writer() do not accept it, so a verbose run of the unchanged module on 3.15 shows: TypeError: _QEventLoop._add_reader() got an unexpected keyword argument 'context' at teardown of test_reader_writer_echo, test_regression_bug13 and test_add_reader_replace, and the first two also fail with TimeoutError (2 failed, 46 passed, 3 errors). Patch 1 below adds context=None to both methods, captures the current context when none is given (as asyncio's own selector loop does), and passes it to call_soon() for the callback. With it, the module passes 48 of 48 on both 3.14 and 3.15. A separate six-case check of explicit and implicit contexts for both readers and writers also passes on both. Upstream master (d47e582) still has the old signatures. Tested with PyQt5 in an amd64 sid container on 2026-11-23: python3.14 3.14.10-1, python3.15 3.15.2-1, PyQt5 5.15.11+dfsg-7, pytest 9.1.1-1. diff --git a/debian/patches/asyncio-selector-callback-context.patch b/debian/patches/asyncio-selector-callback-context.patch new file mode 100644 index 0000000..1e07ec7 --- /dev/null +++ b/debian/patches/asyncio-selector-callback-context.patch @@ -0,0 +1,97 @@ +Description: Preserve asyncio selector callback contexts + Python 3.15 selector transports supply their context when registering + reader and writer callbacks. Accept it and forward it to call_soon so the + Qt notifier dispatch runs in that context. If none is supplied, capture + the registration context as asyncio's selector event loop does. +Author: CyberNative AI LLC <[email protected]> +Bug-Debian: https://bugs.debian.org/1152576 +Forwarded: no +Last-Update: 2026-11-23 +--- a/src/qasync/__init__.py ++++ b/src/qasync/__init__.py +@@ -12,6 +12,7 @@ + + import asyncio + import contextlib ++import contextvars + import functools + import importlib + import inspect +@@ -521,7 +522,7 @@ + """Get time according to event loop's clock.""" + return time.monotonic() + +- def _add_reader(self, fd, callback, *args): ++ def _add_reader(self, fd, callback, *args, context=None): + """Register a callback for when a file descriptor is ready for reading.""" + self._check_closed() + +@@ -535,12 +536,15 @@ + existing.activated["int"].disconnect() + # will get overwritten by the assignment below anyways + ++ if context is None: ++ context = contextvars.copy_context() ++ + notifier = QtCore.QSocketNotifier(_fileno(fd), QtCore.QSocketNotifier.Type.Read) + notifier.setEnabled(True) + self.__log_debug("Adding reader callback for file descriptor %s", fd) + notifier.activated["int"].connect( + lambda: self.__on_notifier_ready( +- self._read_notifiers, notifier, fd, callback, args ++ self._read_notifiers, notifier, fd, callback, args, context + ) # noqa: C812 + ) + self._read_notifiers[fd] = notifier +@@ -560,7 +564,7 @@ + notifier.activated["int"].disconnect() + return True + +- def _add_writer(self, fd, callback, *args): ++ def _add_writer(self, fd, callback, *args, context=None): + """Register a callback for when a file descriptor is ready for writing.""" + self._check_closed() + try: +@@ -573,6 +577,9 @@ + existing.activated["int"].disconnect() + # will get overwritten by the assignment below anyways + ++ if context is None: ++ context = contextvars.copy_context() ++ + notifier = QtCore.QSocketNotifier( + _fileno(fd), + QtCore.QSocketNotifier.Type.Write, +@@ -581,7 +588,7 @@ + self.__log_debug("Adding writer callback for file descriptor %s", fd) + notifier.activated["int"].connect( + lambda: self.__on_notifier_ready( +- self._write_notifiers, notifier, fd, callback, args ++ self._write_notifiers, notifier, fd, callback, args, context + ) # noqa: C812 + ) + self._write_notifiers[fd] = notifier +@@ -615,7 +622,7 @@ + if notifiers.get(fd, None) is notifier: + notifier.setEnabled(True) + +- def __on_notifier_ready(self, notifiers, notifier, fd, callback, args): ++ def __on_notifier_ready(self, notifiers, notifier, fd, callback, args, context): + if fd not in notifiers: + self._logger.warning( + "Socket notifier for fd %s is ready, even though it should " +@@ -633,7 +640,13 @@ + self.__log_debug("Socket notifier for fd %s is ready", fd) + notifier.setEnabled(False) + self.call_soon( +- self.__notifier_cb_wrapper, notifiers, notifier, fd, callback, args ++ self.__notifier_cb_wrapper, ++ notifiers, ++ notifier, ++ fd, ++ callback, ++ args, ++ context=context, + ) + + # Methods for interacting with threads. diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..d771686 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +asyncio-selector-callback-context.patch Prepared by CyberNative AI LLC, an AI-run company, using AI agents.

