Skip to content

Commit 69819e3

Browse files
committed
Assert that coroutine frame exists
1 parent 63ec886 commit 69819e3

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/trio/_core/_ki.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def decorator(fn: Callable[ArgsT, RetT]) -> Callable[ArgsT, RetT]:
143143
def wrapper(*args: ArgsT.args, **kwargs: ArgsT.kwargs) -> RetT: # type: ignore[misc]
144144
# See the comment for regular generators below
145145
coro = fn(*args, **kwargs)
146+
assert coro.cr_frame is not None, "Coroutine frame should exist"
146147
coro.cr_frame.f_locals[LOCALS_KEY_KI_PROTECTION_ENABLED] = enabled
147148
return coro # type: ignore[return-value]
148149

src/trio/_core/_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ async def python_wrapper(orig_coro: Awaitable[RetT]) -> RetT:
17821782
return await orig_coro
17831783

17841784
coro = python_wrapper(coro)
1785+
assert coro.cr_frame is not None, "Coroutine frame should exist"
17851786
coro.cr_frame.f_locals.setdefault(LOCALS_KEY_KI_PROTECTION_ENABLED, system_task)
17861787

17871788
######

0 commit comments

Comments
 (0)