| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,6 +237,10 @@ asyncio | |||
| 237 | 237 | * Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup. | |
| 238 | 238 | (Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.) | |
| 239 | 239 | ||
| 240 | + * :func:`asyncio.iscoroutine` now returns ``False`` for generators as | ||
| 241 | + :mod:`asyncio` does not support legacy generator-based coroutines. | ||
| 242 | + (Contributed by Kumar Aditya in :gh:`102748`.) | ||
| 243 | + | ||
| 240 | 244 | inspect | |
| 241 | 245 | ------- | |
| 242 | 246 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,8 +25,7 @@ def iscoroutinefunction(func): | |||
| 25 | 25 | ||
| 26 | 26 | # Prioritize native coroutine check to speed-up | |
| 27 | 27 | # asyncio.iscoroutine. | |
| 28 | - _COROUTINE_TYPES = (types.CoroutineType, types.GeneratorType, | ||
| 29 | - collections.abc.Coroutine) | ||
| 28 | + _COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine) | ||
| 30 | 29 | _iscoroutine_typecache = set() | |
| 31 | 30 | ||
| 32 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,12 @@ async def foo(): pass | |||
| 119 | 119 | ||
| 120 | 120 | self.assertTrue(asyncio.iscoroutine(FakeCoro())) | |
| 121 | 121 | ||
| 122 | + def test_iscoroutine_generator(self): | ||
| 123 | + def foo(): yield | ||
| 124 | + | ||
| 125 | + self.assertFalse(asyncio.iscoroutine(foo())) | ||
| 126 | + | ||
| 127 | + | ||
| 122 | 128 | def test_iscoroutinefunction(self): | |
| 123 | 129 | async def foo(): pass | |
| 124 | 130 | self.assertTrue(asyncio.iscoroutinefunction(foo)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + :func:`asyncio.iscoroutine` now returns ``False`` for generators as | ||
| 2 | + :mod:`asyncio` does not support legacy generator-based coroutines. | ||
| 3 | + Patch by Kumar Aditya. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments