peps: f156b272f860 (original) (raw)
--- a/pep-0492.txt
+++ b/pep-0492.txt
@@ -112,7 +112,7 @@ Key properties of coroutines:
CO_GENERATOR
flags set.
StopIteration
exceptions are not propagated out of coroutines, and are replaced with aRuntimeError
. For regular generators @@ -132,7 +132,7 @@ allows interoperability between existing in asyncio and native coroutines introduced by this PEP. The function appliesCO_COROUTINE
flag to generator-function's code -object, making it return a coroutine object. +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. @@ -160,10 +160,11 @@ It uses theyield from
implementatio validating its argument.await
only accepts an awaitable, which can be one of: -* A native coroutine object returned from a native coroutine. +* A native coroutine object returned from a *native coroutine
- An object with an
__await__
method returning an iterator. @@ -590,15 +591,15 @@ remains unchanged.** Great effort has been made to make sure that coroutines and generators are treated as distinct concepts: -1. Native coroutine objects do not implement__iter__
and +1. Native coroutine objects do not implement__iter__
and__next__
methods. Therefore, they cannot be iterated over or passed toiter()
,list()
,tuple()
and other built-ins. They also cannot be used in afor..in
loop. An attempt to use__iter__
or__next__
on a *native
-2. Plain generators cannot yield from
native coroutine objects:
+2. Plain generators cannot yield from
native coroutines:
doing so will result in a TypeError
.
3. generator-based coroutines (for asyncio code must be decorated
@@ -606,7 +607,7 @@ 3. generator-based coroutines (for asy
objects*.
4. inspect.isgenerator()
and inspect.isgeneratorfunction()
@@ -614,13 +615,13 @@ Coroutine object methods
''''''''''''''''''''''''
Coroutines are based on generators internally, thus they share the
-implementation. Similarly to generator objects, coroutine objects have
+implementation. Similarly to generator objects, coroutines have
throw()
, send()
and close()
methods. StopIteration
and
-GeneratorExit
play the same role for coroutine objects (although
+GeneratorExit
play the same role for coroutines (although
PEP 479 is enabled by default for coroutines). See PEP 342, PEP 380,
and Python Documentation [11]_ for details.
-throw()
, send()
methods for coroutine objects are used to push
+throw()
, send()
methods for coroutines are used to push
values and raise errors into Future-like objects.
@@ -668,7 +669,7 @@ New Standard Library Functions
details.
inspect.iscoroutinefunction(obj)
returnsTrue
ifobj
is a coroutine function. @@ -677,8 +678,8 @@ New Standard Library Functions inawait
expression. SeeAwait Expression
_ for details.sys.set_coroutine_wrapper(wrapper)
allows to intercept creation
- of coroutine objects.
wrapper
must be a callable that accepts - one argument: a coroutine object or
None
.None
resets the
- of coroutine objects.
wrapper
must be a callable that accepts - one argument: a coroutine object or
None
.None
resets the wrapper. If called twice, the new wrapper replaces the previous one. The function is thread-specific. SeeDebugging Features
_ for more details. @@ -691,28 +692,28 @@ New Standard Library Functions Glossary ======== -:Native coroutine: +:Native coroutine function: A coroutine function is declared withasync def
. It usesawait
andreturn value
; seeNew Coroutine Declaration[](#l1.108) Syntax
_ for details. -:Native coroutine object: +:Native coroutine: Returned from a native coroutine function. SeeAwait Expression
_ for details. -:Generator-based coroutine: +:Generator-based coroutine function: Coroutines based on generator syntax. Most common example are functions decorated with@asyncio.coroutine
. -:Generator-based coroutine object: +:Generator-based coroutine: Returned from a generator-based coroutine function. :Coroutine: Either native coroutine or generator-based coroutine. :Coroutine object:
:Future-like object:
An object with an __await__
method, or a C object with
@@ -723,7 +724,7 @@ Glossary
Expression`_ for details.
:Awaitable: