This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio.iscoroutine() documentation is wrong
Type: Stage: resolved
Components: asyncio, Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: abcd, asvetlov, docs@python, miss-islington, xtreak, yselivanov
Priority: normal Keywords: patch

Created on 2018-09-25 20:32 by abcd, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9611 merged yselivanov, 2018-09-27 19:39
PR 9612 merged miss-islington, 2018-09-27 19:48
PR 9625 closed yselivanov, 2018-09-28 16:21
Messages (6)
msg326404 - (view) Author: (abcd) Date: 2018-09-25 20:32
The documentation states that "This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine."

It seems to be wrong, a method written as follow:

def test(): yield 1

will be evaluated as a coroutine by asyncio.iscoroutine(), even if not decorated. The old doc stated "Return True if obj is a coroutine object, which may be based on a generator or an async def coroutine.", which seems more correct.
msg326415 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-26 01:44
Thanks for the report. I believe this was done as part asyncio docs overhaul and I am adding Yury here. The current docs link to #coroutine from asyncio.iscoroutine whereas the previous docs had the definition inline. I think this is clarified in #awaitables section but takes a round-trip and it's not in #coroutines section which is linked in asyncio.iscoroutine. The below is present in important note in #awaitables and may be this can be added to #coroutine too so that it's not last? Suggestions welcome 

> asyncio also supports legacy generator-based coroutines

I would suggest below for #coroutines :  

> Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines.

Thanks
msg326587 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-09-27 19:42
I'll make a simple fix for the asyncio.coroutine decorator docs.

> I would suggest below for #coroutines :  

>> Coroutines declared with async/await syntax is the preferred way of writing asyncio applications but asyncio also supports legacy generator-based coroutines.

I don't want to further emphasize generator-based coroutines beyond how they are covered right now.  We'll drop support for them in a just a couple of versions anyways.
msg326588 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-09-27 19:48
New changeset 59ee5b12938efbf534f2a19300a847bf6b23a77d by Yury Selivanov in branch 'master':
bpo-34802: Fix asyncio.iscoroutine() docs (GH-9611)
https://github.com/python/cpython/commit/59ee5b12938efbf534f2a19300a847bf6b23a77d
msg326589 - (view) Author: miss-islington (miss-islington) Date: 2018-09-27 19:53
New changeset 85ccedc5b57ddda198e7176ba787e3896435c504 by Miss Islington (bot) in branch '3.7':
bpo-34802: Fix asyncio.iscoroutine() docs (GH-9611)
https://github.com/python/cpython/commit/85ccedc5b57ddda198e7176ba787e3896435c504
msg326591 - (view) Author: (abcd) Date: 2018-09-27 20:20
I think it's much clearer
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78983
2018-09-28 16:21:38yselivanovsetpull_requests: + pull_request9023
2018-09-27 20:20:44abcdsetmessages: + msg326591
2018-09-27 19:57:08yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-09-27 19:53:22miss-islingtonsetnosy: + miss-islington
messages: + msg326589
2018-09-27 19:48:44miss-islingtonsetpull_requests: + pull_request9010
2018-09-27 19:48:33yselivanovsetmessages: + msg326588
2018-09-27 19:42:03yselivanovsetversions: + Python 3.8
nosy: + docs@python

messages: + msg326587

assignee: docs@python
components: + Documentation, asyncio
2018-09-27 19:39:27yselivanovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request9009
2018-09-27 19:34:03brett.cannonsetnosy: + asvetlov
2018-09-26 01:44:51xtreaksetnosy: + xtreak, yselivanov
messages: + msg326415
2018-09-25 20:32:06abcdcreate