pep-0492: Fix differences from what was committed.

This commit is contained in:
Yury Selivanov 2015-05-11 23:47:11 -04:00
parent cec5cff1c9
commit dda4b60269
1 changed files with 24 additions and 24 deletions

View File

@ -110,14 +110,14 @@ Key properties of *coroutines*:
* Internally, two new code object flags were introduced:
- ``CO_COROUTINE`` is used to enable runtime detection of
*coroutines* (and migrating existing code).
- ``CO_NATIVE_COROUTINE`` is used to mark *native coroutines*
- ``CO_COROUTINE`` is used to mark *native coroutines*
(defined with new syntax.)
All coroutines have ``CO_COROUTINE``, ``CO_NATIVE_COROUTINE``, and
``CO_GENERATOR`` flags set.
- ``CO_ITERABLE_COROUTINE`` is used to make *generator-based
coroutines* compatible with *native coroutines* (set by
`types.coroutine()`_ function).
All coroutines have ``CO_GENERATOR`` flag set.
* Regular generators, when called, return a *generator object*;
similarly, coroutines return a *coroutine* object.
@ -139,13 +139,13 @@ A new function ``coroutine(gen)`` is added to the ``types`` module. It
allows interoperability between existing *generator-based coroutines*
in asyncio and *native coroutines* introduced by this PEP.
The function applies ``CO_COROUTINE`` flag to generator-function's code
object, making it return a *coroutine* object.
The function applies ``CO_ITERABLE_COROUTINE`` flag to generator-
function's code object, making it return a *coroutine* object.
The function can be used as a decorator, since it modifies generator-
functions in-place and returns them.
Note, that the ``CO_NATIVE_COROUTINE`` flag is not applied by
Note, that the ``CO_COROUTINE`` flag is not applied by
``types.coroutine()`` to make it possible to separate *native
coroutines* defined with new syntax, from *generator-based coroutines*.
@ -199,8 +199,8 @@ can be one of:
It is a ``TypeError`` if ``__await__`` returns anything but an
iterator.
* Objects defined with CPython C API with a ``tp_await`` function,
returning an iterator (similar to ``__await__`` method).
* Objects defined with CPython C API with a ``tp_as_async->am_await``
function, returning an *iterator* (similar to ``__await__`` method).
It is a ``SyntaxError`` to use ``await`` outside of an ``async def``
function (like it is a ``SyntaxError`` to use ``yield`` outside of
@ -589,9 +589,8 @@ Coroutine objects
Differences from generators
'''''''''''''''''''''''''''
This section applies only to *native coroutines* with
``CO_NATIVE_COROUTINE`` flag, i.e. defined with the new ``async def``
syntax.
This section applies only to *native coroutines* with ``CO_COROUTINE``
flag, i.e. defined with the new ``async def`` syntax.
**The behavior of existing *generator-based coroutines* in asyncio
remains unchanged.**
@ -725,11 +724,11 @@ Glossary
:Future-like object:
An object with an ``__await__`` method, or a C object with
``tp_await`` function, returning an iterator. Can be consumed by
an ``await`` expression in a coroutine. A coroutine waiting for a
Future-like object is suspended until the Future-like object's
``__await__`` completes, and returns the result. See `Await
Expression`_ for details.
``tp_as_async->am_await`` function, returning an *iterator*. Can be
consumed by an ``await`` expression in a coroutine. A coroutine
waiting for a Future-like object is suspended until the Future-like
object's ``__await__`` completes, and returns the result. See
`Await Expression`_ for details.
:Awaitable:
A *Future-like* object or a *coroutine* object. See `Await
@ -1294,14 +1293,15 @@ List of high-level changes and new protocols
keyword.
2. New ``__await__`` method for Future-like objects, and new
``tp_await`` slot in ``PyTypeObject``.
``tp_as_async->am_await`` slot in ``PyTypeObject``.
3. New syntax for asynchronous context managers: ``async with``. And
associated protocol with ``__aenter__`` and ``__aexit__`` methods.
4. New syntax for asynchronous iteration: ``async for``. And
associated protocol with ``__aiter__``, ``__aexit__`` and new built-
in exception ``StopAsyncIteration``.
in exception ``StopAsyncIteration``. New ``tp_as_async->am_aiter``
and ``tp_as_async->am_anext`` slots in ``PyTypeObject``.
5. New AST nodes: ``AsyncFunctionDef``, ``AsyncFor``, ``AsyncWith``,
``Await``.
@ -1311,7 +1311,7 @@ List of high-level changes and new protocols
``inspect.iscoroutinefunction()``, ``inspect.iscoroutine()``,
and ``inspect.isawaitable()``.
7. New ``CO_COROUTINE`` and ``CO_NATIVE_COROUTINE`` bit flags for code
7. New ``CO_COROUTINE`` and ``CO_ITERABLE_COROUTINE`` bit flags for code
objects.
While the list of changes and new things is not short, it is important
@ -1408,8 +1408,8 @@ I thank Guido van Rossum, Victor Stinner, Elvis Pranskevichus, Andrew
Svetlov, Łukasz Langa, Greg Ewing, Stephen J. Turnbull, Jim J. Jewett,
Brett Cannon, Nick Coghlan, Steven D'Aprano, Paul Moore, Nathaniel
Smith, Ethan Furman, Stefan Behnel, Paul Sokolovsky, Victor Petrovykh,
and many others for their feedback, ideas, edits, criticism, and
discussions around this PEP.
and many others for their feedback, ideas, edits, criticism, code
reviews, and discussions around this PEP.
Copyright