cpython/Include
Yury Selivanov 5376ba9630 Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:

1. Coroutines now have a distinct, separate from generators
   type at the C level: PyGen_Type, and a new typedef PyCoroObject.
   PyCoroObject shares the initial segment of struct layout with
   PyGenObject, making it possible to reuse existing generators
   machinery.  The new type is exposed as 'types.CoroutineType'.

   As a consequence of having a new type, CO_GENERATOR flag is
   no longer applied to coroutines.

2. Having a separate type for coroutines made it possible to add
   an __await__ method to the type.  Although it is not used by the
   interpreter (see details on that below), it makes coroutines
   naturally (without using __instancecheck__) conform to
   collections.abc.Coroutine and collections.abc.Awaitable ABCs.

   [The __instancecheck__ is still used for generator-based
   coroutines, as we don't want to add __await__ for generators.]

3. Add new opcode: GET_YIELD_FROM_ITER.  The opcode is needed to
   allow passing native coroutines to the YIELD_FROM opcode.

   Before this change, 'yield from o' expression was compiled to:

      (o)
      GET_ITER
      LOAD_CONST
      YIELD_FROM

   Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.

   The reason for adding a new opcode is that GET_ITER is used
   in some contexts (such as 'for .. in' loops) where passing
   a coroutine object is invalid.

4. Add two new introspection functions to the inspec module:
   getcoroutinestate(c) and getcoroutinelocals(c).

5. inspect.iscoroutine(o) is updated to test if 'o' is a native
   coroutine object.  Before this commit it used abc.Coroutine,
   and it was requested to update inspect.isgenerator(o) to use
   abc.Generator; it was decided, however, that inspect functions
   should really be tailored for checking for native types.

6. sys.set_coroutine_wrapper(w) API is updated to work with only
   native coroutines.  Since types.coroutine decorator supports
   any type of callables now, it would be confusing that it does
   not work for all types of coroutines.

7. Exceptions logic in generators C implementation was updated
   to raise clearer messages for coroutines:

   Before: TypeError("generator raised StopIteration")
   After: TypeError("coroutine raised StopIteration")
2015-06-22 12:19:30 -04:00
..
Python-ast.h PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
Python.h Issue #16991: Add a C implementation of collections.OrderedDict. 2015-05-29 22:21:39 -06:00
abstract.h Issue #23571: _Py_CheckFunctionResult() now gives the name of the function 2015-03-21 15:04:43 +01:00
accu.h
asdl.h Fix compiler warning on Windows 64-bit: asdl_seq_SET() stores the index parameter 2013-11-16 00:16:58 +01:00
ast.h Close #11619: The parser and the import machinery do not encode Unicode 2013-08-26 22:28:21 +02:00
bitset.h
bltinmodule.h
boolobject.h
bytearrayobject.h fix comment 2013-10-05 16:28:04 -04:00
bytes_methods.h Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer() 2015-02-03 01:25:42 +02:00
bytesobject.h Issue20284: Implement PEP461 2015-01-23 20:05:18 -08:00
cellobject.h
ceval.h Added the const qualifier for char* argument of Py_EnterRecursiveCall(). 2015-06-21 16:27:09 +03:00
classobject.h
code.h PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
codecs.h Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
compile.h PEP 479: Change StopIteration handling inside generators. 2015-05-09 11:44:30 -04:00
complexobject.h Issue #21803: remove macro indirections in complexobject.h 2014-07-07 18:49:30 -04:00
datetime.h #18466: fix more typos. Patch by Févry Thibault. 2013-08-17 16:57:41 +03:00
descrobject.h
dictobject.h Issue #16991: Use PyObject_TypeCheck instead of PyObject_IsInstance. 2015-05-30 09:29:53 -06:00
dtoa.h
dynamic_annotations.h fix instances of consecutive articles (closes #23221) 2015-01-13 09:17:24 -05:00
enumobject.h
errcode.h
eval.h
fileobject.h Issue #23524: Replace _PyVerify_fd function with calling _set_thread_local_invalid_parameter_handler on every thread. 2015-03-06 14:47:02 -08:00
fileutils.h Issue #23524: Replace _PyVerify_fd function with calls to _set_thread_local_invalid_parameter_handler. 2015-04-12 00:26:27 -04:00
floatobject.h
frameobject.h Issue #14432: Remove the thread state field from the frame structure. Fix a 2013-12-13 02:01:38 +01:00
funcobject.h
genobject.h Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
graminit.h PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
grammar.h Removed trailing tabs. 2015-03-21 09:25:53 +02:00
import.h (Merge 3.3) Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes. 2013-12-10 01:20:39 +01:00
intrcheck.h
iterobject.h
listobject.h Issue #24221: Small optimizations for heapq. 2015-05-22 00:41:57 -07:00
longintrepr.h Issue #18783: Removed existing mentions of Python long type in docstrings, 2013-08-27 19:40:23 +03:00
longobject.h Issue #22486: Added the math.gcd() function. The fractions.gcd() function now is 2015-05-13 00:19:51 +03:00
marshal.h Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
memoryobject.h Closes #22668: Merge from 3.4. 2015-01-29 14:29:51 +01:00
metagrammar.h
methodobject.h Removed trailing whitespaces in miscalenous files. 2015-04-03 19:42:32 +03:00
modsupport.h Issue 24365: Conditionalize PEP 489 additions to the stable ABI 2015-06-02 19:06:47 -04:00
moduleobject.h Issue 24365: Conditionalize PEP 489 additions to the stable ABI 2015-06-02 19:06:47 -04:00
namespaceobject.h
node.h Removed trailing tabs. 2015-03-21 09:25:53 +02:00
object.h Issue 24017: Drop getawaitablefunc and friends in favor of unaryfunc. 2015-05-28 11:21:31 -04:00
objimpl.h Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(), 2014-05-02 22:31:14 +02:00
odictobject.h Issue #24347: Set KeyError if PyDict_GetItemWithError returns NULL. 2015-06-01 22:59:08 -06:00
opcode.h Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
osdefs.h Issue #22591: Drop support of MS-DOS 2014-10-10 11:55:41 +02:00
parsetok.h Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
patchlevel.h Post-release updates for Python 3.5.0b2. 2015-05-31 21:42:35 -07:00
pgen.h
pgenheaders.h
py_curses.h
pyarena.h
pyatomic.h Issue #23644: Fix issues with C++ when compiling Python extensions 2015-03-17 22:53:27 +01:00
pycapsule.h
pyctype.h
pydebug.h Issue #22869: Split pythonrun into two modules 2014-11-20 21:39:37 +10:00
pyerrors.h PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
pyexpat.h Issue #13612: handle unknown encodings without a buffer overflow. 2013-05-25 05:25:48 -07:00
pyfpe.h
pygetopt.h
pyhash.h Issue #19526: Exclude all new API from the stable ABI. 2014-01-03 21:36:49 +01:00
pylifecycle.h Issue #22869: Split pythonrun into two modules 2014-11-20 21:39:37 +10:00
pymacconfig.h
pymacro.h Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY() 2014-05-14 17:24:35 +02:00
pymath.h
pymem.h Issue #21233: Rename the C structure "PyMemAllocator" to "PyMemAllocatorEx" to 2014-06-02 21:57:10 +02:00
pyport.h Issue #23943: Fix typos. Patch by Piotr Kasprzyk. 2015-04-14 09:35:51 +03:00
pystate.h Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully 2015-06-02 18:43:51 -04:00
pystrcmp.h
pystrhex.h Add the files missing from c9f1630cf2b1 for issue9951. 2015-04-26 00:41:00 +00:00
pystrtod.h
pythonrun.h PEP 479: Change StopIteration handling inside generators. 2015-05-09 11:44:30 -04:00
pythread.h
pytime.h Issue #23834: Fix the default socket timeout 2015-04-09 10:23:12 +02:00
rangeobject.h
setobject.h Move the set search finger before the smalltable. 2015-01-29 22:00:32 -08:00
sliceobject.h Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
structmember.h
structseq.h Issue #18520: Add a new PyStructSequence_InitType2() function, same than 2013-07-22 22:24:54 +02:00
symtable.h remove the concept of an unoptimized function scope from the compiler, since it can't happen anymore 2015-04-27 21:44:22 -04:00
sysmodule.h Issue #22193: Fixed integer overflow error in sys.getsizeof(). 2014-11-15 13:21:37 +02:00
token.h PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
traceback.h Issue #24436: Added const qualifiers for char* arguments of _PyTraceback_Add. 2015-06-21 15:59:46 +03:00
tupleobject.h
typeslots.h Issue 24365: Conditionalize PEP 489 additions to the stable ABI 2015-06-02 19:06:47 -04:00
ucnhash.h Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
unicodeobject.h Issue #23908: os functions now reject paths with embedded null character 2015-04-20 10:12:28 +03:00
warnings.h Issue #19526: Exclude all new API from the stable ABI. 2014-01-03 21:36:49 +01:00
weakrefobject.h Closes #13867: remove untrue comment about PyWeakref_Check(). 2013-10-08 19:50:26 +02:00