Skip to content

Commit cd766fe

Browse files
committed
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.
1 parent e11315d commit cd766fe

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Lib/test/test_asyncio/test_tools.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22

33
from asyncio import tools
44

5-
from collections import namedtuple
5+
import _remote_debugging
66

7-
LocationInfo = namedtuple('LocationInfo', ['lineno', 'end_lineno', 'col_offset', 'end_col_offset'], defaults=[None]*4)
8-
FrameInfo = namedtuple('FrameInfo', ['funcname', 'filename', 'location'])
9-
CoroInfo = namedtuple('CoroInfo', ['call_stack', 'task_name'])
10-
TaskInfo = namedtuple('TaskInfo', ['task_id', 'task_name', 'coroutine_stack', 'awaited_by'])
11-
AwaitedInfo = namedtuple('AwaitedInfo', ['thread_id', 'awaited_by'])
7+
8+
def LocationInfo(lineno, end_lineno=None, col_offset=None, end_col_offset=None):
9+
return _remote_debugging.LocationInfo((lineno, end_lineno, col_offset, end_col_offset))
10+
11+
12+
def FrameInfo(funcname, filename, location, opcode=None):
13+
return _remote_debugging.FrameInfo((filename, location, funcname, opcode))
14+
15+
16+
def CoroInfo(call_stack, task_name):
17+
return _remote_debugging.CoroInfo((call_stack, task_name))
18+
19+
20+
def TaskInfo(task_id, task_name, coroutine_stack, awaited_by):
21+
return _remote_debugging.TaskInfo((task_id, task_name, coroutine_stack, awaited_by))
22+
23+
24+
def AwaitedInfo(thread_id, awaited_by):
25+
return _remote_debugging.AwaitedInfo((thread_id, awaited_by))
1226

1327

1428
# mock output of get_all_awaited_by function.

0 commit comments

Comments
 (0)