We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dba7cb9 commit 9961179Copy full SHA for 9961179
1 file changed
Lib/inspect.py
@@ -307,23 +307,17 @@ def isgeneratorfunction(obj):
307
308
def _has_coroutine_mark(f):
309
while True:
310
+ # Direct marker check
311
if getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark:
312
return True
313
- pm = getattr(f, "__partialmethod__", None)
314
- if isinstance(pm, functools.partialmethod):
315
- f = pm
316
- continue
317
-
318
- if isinstance(f, functools.partialmethod):
319
- f = getattr(f, 'func')
320
321
+ # Methods: unwrap first (methods cannot be coroutine-marked)
322
if ismethod(f):
323
f = f.__func__
324
continue
325
326
- if isinstance(f, functools.partial):
+ # partial and partialmethod share .func
+ if isinstance(f, (functools.partial, functools.partialmethod)):
327
f = f.func
328
329
0 commit comments