python / cpython

The Python programming language
https://www.python.org
Other
63.14k stars 30.23k forks source link

Outdated description of async iterables in documentation of async for statement #86045

Closed e00df3b0-5162-4b9e-b195-1bd93434eed5 closed 2 years ago

e00df3b0-5162-4b9e-b195-1bd93434eed5 commented 4 years ago
BPO 41879
Nosy @asvetlov, @1st1, @miss-islington, @nickgaya
PRs
  • python/cpython#23548
  • python/cpython#23749
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['3.7', '3.8', '3.9', '3.10', 'expert-asyncio', 'docs'] title = 'Outdated description of async iterables in documentation of async for statement' updated_at = user = 'https://github.com/nickgaya' ``` bugs.python.org fields: ```python activity = actor = 'asvetlov' assignee = 'docs@python' closed = True closed_date = closer = 'asvetlov' components = ['Documentation', 'asyncio'] creation = creator = 'nickgaya' dependencies = [] files = [] hgrepos = [] issue_num = 41879 keywords = ['patch'] message_count = 6.0 messages = ['377621', '382013', '382036', '382040', '382859', '382930'] nosy_count = 5.0 nosy_names = ['asvetlov', 'docs@python', 'yselivanov', 'miss-islington', 'nickgaya'] pr_nums = ['23548', '23749'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue41879' versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10'] ```

    e00df3b0-5162-4b9e-b195-1bd93434eed5 commented 4 years ago

    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:

    asvetlov commented 3 years ago

    Both mentioned links have the correct code. They use sync __aiter and async __anext

    e00df3b0-5162-4b9e-b195-1bd93434eed5 commented 3 years ago

    As described above, the issue is in the textual description, not the code snippet. I have opened a GitHub PR with a fix.

    asvetlov commented 3 years ago

    You are right.

    miss-islington commented 3 years ago

    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

    miss-islington commented 3 years ago

    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