File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -238,13 +238,17 @@ def wrapper(*args, **kwds):
238
238
w .__qualname__ = getattr (func , '__qualname__' , None )
239
239
return w
240
240
241
- wrapper ._is_coroutine = True # For iscoroutinefunction().
241
+ wrapper ._is_coroutine = _is_coroutine # For iscoroutinefunction().
242
242
return wrapper
243
243
244
244
245
+ # A marker for iscoroutinefunction.
246
+ _is_coroutine = object ()
247
+
248
+
245
249
def iscoroutinefunction (func ):
246
250
"""Return True if func is a decorated coroutine function."""
247
- return (getattr (func , '_is_coroutine' , False ) or
251
+ return (getattr (func , '_is_coroutine' , None ) is _is_coroutine or
248
252
_inspect_iscoroutinefunction (func ))
249
253
250
254
Original file line number Diff line number Diff line change @@ -1376,6 +1376,8 @@ def fn2():
1376
1376
yield
1377
1377
self .assertTrue (asyncio .iscoroutinefunction (fn2 ))
1378
1378
1379
+ self .assertFalse (asyncio .iscoroutinefunction (mock .Mock ()))
1380
+
1379
1381
def test_yield_vs_yield_from (self ):
1380
1382
fut = asyncio .Future (loop = self .loop )
1381
1383
You can’t perform that action at this time.
0 commit comments