Bug report
Bug description:
test.test_asyncio.test_base_events is calling a real system function with a mocked object, which is causing failures. It seems the test case test_create_connection_happy_eyeballs_ipv4_only is failing.
nick@COMPY D:\src\cpython-trunk>pcbuild\amd64\python.exe -m test
== CPython 3.16.0a0 (heads/main:11f032f904c, Jun 16 2026, 12:13:34) [MSC v.1951 64 bit (AMD64)]
== Windows-11-10.0.26200-SP0 little-endian
== Python build: release with_assert
== cwd: D:\src\cpython-trunk\build\test_python_worker_17156æ
== CPU count: 32
== encodings: locale=cp1252 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests
Using random seed: 1122715071
0:00:00 mem: 30.7 MiB Run 505 tests sequentially in a single process
0:00:00 mem: 30.7 MiB [ 1/505] test.test_asyncio.test_base_events
Exception in callback _ProactorReadPipeTransport._loop_reading()
handle: <Handle _ProactorReadPipeTransport._loop_reading()>
Traceback (most recent call last):
File "D:\src\cpython-trunk\Lib\asyncio\events.py", line 94, in _run
self._context.run(self._callback, *self._args)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\src\cpython-trunk\Lib\asyncio\proactor_events.py", line 306, in _loop_reading
self._read_fut = self._loop._proactor.recv_into(self._sock, self._data)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\src\cpython-trunk\Lib\asyncio\windows_events.py", line 497, in recv_into
self._register_with_iocp(conn)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "D:\src\cpython-trunk\Lib\asyncio\windows_events.py", line 713, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: an integer is required
The TypeError is coming from the return value from obj.fileno() which is returning a <class 'unittest.mock.MagicMock'>.
Tracing the source of that object, it seems it's being created in Lib/test/test_asyncio/utils.py - mock_nonblocking_socket() which doesn't have anything setup to handle fileno() calls. At this point I'm not sure what would be correct to return here as _register_with_iocp() is calling a real system function which would expect a real handle.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Bug report
Bug description:
test.test_asyncio.test_base_events is calling a real system function with a mocked object, which is causing failures. It seems the test case test_create_connection_happy_eyeballs_ipv4_only is failing.
The TypeError is coming from the return value from
obj.fileno()which is returning a<class 'unittest.mock.MagicMock'>.Tracing the source of that object, it seems it's being created in
Lib/test/test_asyncio/utils.py-mock_nonblocking_socket()which doesn't have anything setup to handlefileno()calls. At this point I'm not sure what would be correct to return here as_register_with_iocp()is calling a real system function which would expect a real handle.CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows