From 4335f709768682d5232a583522ed82906a88e64a Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:10:58 +0000 Subject: [PATCH 1/8] rm legacy support for generators as coroutines --- Lib/asyncio/coroutines.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index 7fda0e449d500a..ab4f30eb51ba2c 100644 --- a/Lib/asyncio/coroutines.py +++ b/Lib/asyncio/coroutines.py @@ -25,8 +25,7 @@ def iscoroutinefunction(func): # Prioritize native coroutine check to speed-up # asyncio.iscoroutine. -_COROUTINE_TYPES = (types.CoroutineType, types.GeneratorType, - collections.abc.Coroutine) +_COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine) _iscoroutine_typecache = set() From f161b44ce7520cb8f04bdf602f8221a084905fa9 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:17:31 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst diff --git a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst new file mode 100644 index 00000000000000..da3d6be6e04070 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst @@ -0,0 +1 @@ +:func:`asyncio.iscoroutine` now returns :const:`False` for generators as :mod:`asyncio` does not supports legacy generator based coroutines. Patch by Kumar Aditya. From 87792d5753874e2a1c7e4df1ce49137bf4db7acb Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:19:49 +0000 Subject: [PATCH 3/8] add whatsnew --- Doc/whatsnew/3.12.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 217ffec1ee1007..f68cf6eee4e03c 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -237,6 +237,10 @@ asyncio * Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup. (Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.) +* :func:`asyncio.iscoroutine` now returns :const:`False` for generators as + :mod:`asyncio` does not supports legacy generator based coroutines. + (Contributed by Kumar Aditya in :gh:`102748`.) + inspect ------- From 0e0897a006d665d4b94d99802de6c081d5f0eb1c Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:22:13 +0000 Subject: [PATCH 4/8] add test --- Lib/test/test_asyncio/test_pep492.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index f833f788dcb98f..dc25a46985e349 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -119,6 +119,12 @@ async def foo(): pass self.assertTrue(asyncio.iscoroutine(FakeCoro())) + def test_iscoroutine_generator(self): + def foo(): yield + + self.assertFalse(asyncio.iscoroutine(foo())) + + def test_iscoroutinefunction(self): async def foo(): pass self.assertTrue(asyncio.iscoroutinefunction(foo)) From 05c0944944529220c78605312c495dc250aa4fb0 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 08:24:11 +0000 Subject: [PATCH 5/8] wrap lines --- Doc/whatsnew/3.12.rst | 2 +- .../Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index f68cf6eee4e03c..d7cd3514ef556c 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -238,7 +238,7 @@ asyncio (Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.) * :func:`asyncio.iscoroutine` now returns :const:`False` for generators as - :mod:`asyncio` does not supports legacy generator based coroutines. + :mod:`asyncio` does not supports legacy generator-based coroutines. (Contributed by Kumar Aditya in :gh:`102748`.) inspect diff --git a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst index da3d6be6e04070..84cf5d4fdfad42 100644 --- a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst +++ b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst @@ -1 +1,3 @@ -:func:`asyncio.iscoroutine` now returns :const:`False` for generators as :mod:`asyncio` does not supports legacy generator based coroutines. Patch by Kumar Aditya. +:func:`asyncio.iscoroutine` now returns :const:`False` for generators as +:mod:`asyncio` does not supports legacy generator-based coroutines. +Patch by Kumar Aditya. From 47caefddf928455fbcfdbd63ea27be8e6f8fe0d8 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 14:01:48 +0530 Subject: [PATCH 6/8] Apply suggestions from code review Co-authored-by: Alex Waygood --- Doc/whatsnew/3.12.rst | 2 +- .../next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index d7cd3514ef556c..38f95ccc89ac29 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -237,7 +237,7 @@ asyncio * Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup. (Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.) -* :func:`asyncio.iscoroutine` now returns :const:`False` for generators as +* :func:`asyncio.iscoroutine` now returns ``False`` for generators as :mod:`asyncio` does not supports legacy generator-based coroutines. (Contributed by Kumar Aditya in :gh:`102748`.) diff --git a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst index 84cf5d4fdfad42..83f0f599d1859f 100644 --- a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst +++ b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst @@ -1,3 +1,3 @@ -:func:`asyncio.iscoroutine` now returns :const:`False` for generators as +:func:`asyncio.iscoroutine` now returns ``False`` for generators as :mod:`asyncio` does not supports legacy generator-based coroutines. Patch by Kumar Aditya. From 31049b180120ad26f52dc1db4ca72b4be6fec85c Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 14:02:42 +0530 Subject: [PATCH 7/8] Update Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst Co-authored-by: Alex Waygood --- .../next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst index 83f0f599d1859f..b1dc67f38fe85d 100644 --- a/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst +++ b/Misc/NEWS.d/next/Library/2023-03-16-08-17-29.gh-issue-102748.WNACpI.rst @@ -1,3 +1,3 @@ :func:`asyncio.iscoroutine` now returns ``False`` for generators as -:mod:`asyncio` does not supports legacy generator-based coroutines. +:mod:`asyncio` does not support legacy generator-based coroutines. Patch by Kumar Aditya. From 14ea9a66a0ce1b2a035fdda4a34e83293fa33689 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 16 Mar 2023 14:02:50 +0530 Subject: [PATCH 8/8] Update Doc/whatsnew/3.12.rst Co-authored-by: Alex Waygood --- Doc/whatsnew/3.12.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 38f95ccc89ac29..b9c668543e1b73 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -238,7 +238,7 @@ asyncio (Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.) * :func:`asyncio.iscoroutine` now returns ``False`` for generators as - :mod:`asyncio` does not supports legacy generator-based coroutines. + :mod:`asyncio` does not support legacy generator-based coroutines. (Contributed by Kumar Aditya in :gh:`102748`.) inspect