Skip to content

Commit 5d5c324

Browse files
authored
Reorder coroutine marker check after method unwrapping
1 parent 1f05728 commit 5d5c324

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/inspect.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,15 @@ def isgeneratorfunction(obj):
307307

308308
def _has_coroutine_mark(f):
309309
while True:
310-
# Direct marker check
311-
if getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark:
312-
return True
313-
314310
# Methods: unwrap first (methods cannot be coroutine-marked)
315311
if ismethod(f):
316312
f = f.__func__
317313
continue
318314

315+
# Direct marker check
316+
if getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark:
317+
return True
318+
319319
# Functions created by partialmethod descriptors keep a __partialmethod__ reference
320320
pm = getattr(f, "__partialmethod__", None)
321321
if isinstance(pm, functools.partialmethod):
@@ -329,7 +329,6 @@ def _has_coroutine_mark(f):
329329

330330
return False
331331

332-
333332
def markcoroutinefunction(func):
334333
"""
335334
Decorator to ensure callable is recognised as a coroutine function.

0 commit comments

Comments
 (0)