From cd766fe17bd3db77150fe31090a2191e8a0b4696 Mon Sep 17 00:00:00 2001 From: johnslavik Date: Mon, 13 Apr 2026 22:54:25 +0200 Subject: [PATCH] gh-143955: Use _remote_debugging structs directly in test_tools Replace namedtuple reimplementations with factory helpers that wrap the real _remote_debugging structseq types. This prevents silent drift between test stubs and production structs, as previously occurred in gh-142394/gh-143952. --- Lib/test/test_asyncio/test_tools.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_asyncio/test_tools.py b/Lib/test/test_asyncio/test_tools.py index 1ab51a6ca3e49b..df934164eb9fd6 100644 --- a/Lib/test/test_asyncio/test_tools.py +++ b/Lib/test/test_asyncio/test_tools.py @@ -2,13 +2,27 @@ from asyncio import tools -from collections import namedtuple +import _remote_debugging -LocationInfo = namedtuple('LocationInfo', ['lineno', 'end_lineno', 'col_offset', 'end_col_offset'], defaults=[None]*4) -FrameInfo = namedtuple('FrameInfo', ['funcname', 'filename', 'location']) -CoroInfo = namedtuple('CoroInfo', ['call_stack', 'task_name']) -TaskInfo = namedtuple('TaskInfo', ['task_id', 'task_name', 'coroutine_stack', 'awaited_by']) -AwaitedInfo = namedtuple('AwaitedInfo', ['thread_id', 'awaited_by']) + +def LocationInfo(lineno, end_lineno=None, col_offset=None, end_col_offset=None): + return _remote_debugging.LocationInfo((lineno, end_lineno, col_offset, end_col_offset)) + + +def FrameInfo(funcname, filename, location, opcode=None): + return _remote_debugging.FrameInfo((filename, location, funcname, opcode)) + + +def CoroInfo(call_stack, task_name): + return _remote_debugging.CoroInfo((call_stack, task_name)) + + +def TaskInfo(task_id, task_name, coroutine_stack, awaited_by): + return _remote_debugging.TaskInfo((task_id, task_name, coroutine_stack, awaited_by)) + + +def AwaitedInfo(thread_id, awaited_by): + return _remote_debugging.AwaitedInfo((thread_id, awaited_by)) # mock output of get_all_awaited_by function.