classification
Title: Outdated description of async iterables in documentation of async for statement
Type: Stage: patch review
Components: asyncio, Documentation Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, docs@python, miss-islington, nickgaya, yselivanov
Priority: normal Keywords: patch

Created on 2020-09-28 20:15 by nickgaya, last changed 2020-12-13 04:24 by miss-islington.

Pull Requests
URL Status Linked Edit
PR 23548 merged nickgaya, 2020-11-29 04:33
PR 23749 merged miss-islington, 2020-12-13 00:55
Messages (6)
msg377621 - (view) Author: Nick Gaya (nickgaya) * Date: 2020-09-28 20:15
The documentation for the `async for` statement incorrectly states that "An asynchronous iterable is able to call asynchronous code in its iter implementation". Actually, this behavior was deprecated in Python 3.6 and removed in Python 3.7.  As of Python 3.7, the `__aiter__()` method must return an asynchronous iterator directly.

Suggested fix: Update the `async for` statement description for Python 3.7+ to match the "Asynchronous Iterators" section in the data model documentation.

> An :term:`asynchronous iterator` can call asynchronous code in its *next* method.

Relevant documentation:
- https://docs.python.org/3/reference/compound_stmts.html#the-async-for-statement
- https://docs.python.org/3/reference/datamodel.html#asynchronous-iterators
msg382013 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-11-28 20:21
Both mentioned links have the correct code.
They use sync __aiter__ and async __anext__
msg382036 - (view) Author: Nick Gaya (nickgaya) * Date: 2020-11-29 04:39
As described above, the issue is in the textual description, not the code snippet. I have opened a GitHub PR with a fix.
msg382040 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-11-29 07:01
You are right.
msg382859 - (view) Author: miss-islington (miss-islington) Date: 2020-12-11 08:27
New changeset 4b8cdfcb22fbeaab9d954cb693a7fb3362a382b6 by Nick Gaya in branch 'master':
bpo-41879: Doc: Fix description of async for statement (GH-23548)
https://github.com/python/cpython/commit/4b8cdfcb22fbeaab9d954cb693a7fb3362a382b6
msg382930 - (view) Author: miss-islington (miss-islington) Date: 2020-12-13 04:24
New changeset be9e4402db64564f7bf0fedb3769cead46c0d4c4 by Miss Islington (bot) in branch '3.9':
[3.9] bpo-41879: Doc: Fix description of async for statement (GH-23548) (GH-23749)
https://github.com/python/cpython/commit/be9e4402db64564f7bf0fedb3769cead46c0d4c4
History
Date User Action Args
2020-12-13 04:24:55miss-islingtonsetmessages: + msg382930
2020-12-13 00:55:09miss-islingtonsetkeywords: + patch
stage: resolved -> patch review
pull_requests: + pull_request22607
2020-12-11 08:27:51miss-islingtonsetnosy: + miss-islington
messages: + msg382859
2020-11-29 07:01:05asvetlovsetmessages: + msg382040
2020-11-29 04:39:40nickgayasetstatus: closed -> open
resolution: out of date ->
messages: + msg382036
2020-11-29 04:33:09nickgayasetpull_requests: + pull_request22427
2020-11-28 20:21:28asvetlovsetstatus: open -> closed
resolution: out of date
messages: + msg382013

stage: resolved
2020-09-29 03:00:11xtreaksetnosy: + asvetlov, yselivanov
components: + asyncio
2020-09-28 20:15:35nickgayacreate