Skip to content

Commit 6238174

Browse files
[3.13] gh-120200: Fix inspect.iscoroutinefunction(inspect) is True corner case (GH-120214) (#120237)
gh-120200: Fix `inspect.iscoroutinefunction(inspect) is True` corner case (GH-120214) (cherry picked from commit 10fb1b8) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent afef6b5 commit 6238174

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Lib/inspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,21 +403,21 @@ def isgeneratorfunction(obj):
403403
return _has_code_flag(obj, CO_GENERATOR)
404404

405405
# A marker for markcoroutinefunction and iscoroutinefunction.
406-
_is_coroutine_marker = object()
406+
_is_coroutine_mark = object()
407407

408408
def _has_coroutine_mark(f):
409409
while ismethod(f):
410410
f = f.__func__
411411
f = functools._unwrap_partial(f)
412-
return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_marker
412+
return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark
413413

414414
def markcoroutinefunction(func):
415415
"""
416416
Decorator to ensure callable is recognised as a coroutine function.
417417
"""
418418
if hasattr(func, '__func__'):
419419
func = func.__func__
420-
func._is_coroutine_marker = _is_coroutine_marker
420+
func._is_coroutine_marker = _is_coroutine_mark
421421
return func
422422

423423
def iscoroutinefunction(obj):

Lib/test/test_inspect/test_inspect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class PMClass:
235235
gen_coroutine_function_example))))
236236
self.assertFalse(inspect.iscoroutinefunction(gen_coro_pmi))
237237
self.assertFalse(inspect.iscoroutinefunction(gen_coro_pmc))
238+
self.assertFalse(inspect.iscoroutinefunction(inspect))
238239
self.assertFalse(inspect.iscoroutine(gen_coro))
239240

240241
self.assertTrue(

0 commit comments

Comments
 (0)