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 Issue #14387 : undefine 'small' so that it doesn't clash with Windows headers. 2012-03-22 23:10:37 +00:00
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 these builtins have to be initialized 2009-05-09 18:10:51 +00:00
boolobject.h #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. 2007-12-19 02:45:37 +00:00
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 Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
ceval.h Added the const qualifier for char* argument of Py_EnterRecursiveCall(). 2015-06-21 16:27:09 +03:00
classobject.h Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
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 Issue #13577: various kinds of descriptors now have a __qualname__ attribute. 2011-12-12 13:47:25 +01:00
dictobject.h Issue #16991: Use PyObject_TypeCheck instead of PyObject_IsInstance. 2015-05-30 09:29:53 -06:00
dtoa.h Issue #14521: Make result of float('nan') and float('-nan') more consistent across platforms. Further, don't rely on Py_HUGE_VAL for float('inf'). 2012-04-29 15:31:56 +01:00
dynamic_annotations.h fix instances of consecutive articles (closes #23221) 2015-01-13 09:17:24 -05:00
enumobject.h
errcode.h Issue #12705: Raise SyntaxError when compiling multiple statements as single interactive statement 2012-01-19 01:08:41 -06:00
eval.h Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
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 Issue #14785: Add sys._debugmallocstats() to help debug low-level memory allocation issues 2012-06-22 14:55:41 -04:00
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 PEP 3155 / issue #13448: Qualified name for classes and functions. 2011-11-25 18:56:07 +01:00
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 Issue #12328: Under Windows, refactor handling of Ctrl-C events and 2011-11-21 21:26:56 +01:00
iterobject.h Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI. 2012-04-05 00:04:20 +02:00
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 Eric Snow's implementation of PEP 421. 2012-06-03 16:18:47 -04:00
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 Issue #12567: The curses module uses Unicode functions for Unicode arguments 2011-11-25 22:10:02 +01:00
pyarena.h Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
pyatomic.h Issue #23644: Fix issues with C++ when compiling Python extensions 2015-03-17 22:53:27 +01:00
pycapsule.h Merged revisions 88517 via svnmerge from 2011-02-22 23:43:57 +00:00
pyctype.h Try to fix linking failures under Windows 2011-10-04 14:43:47 +02:00
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 Remove trailing whitespace in order to silence warnings on HP-UX. 2012-08-31 17:11:39 -04:00
pygetopt.h Fix test failure in test_cmd_line by initializing the hash secret at the earliest point. 2012-02-21 19:03:47 +01:00
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 #11565: Merge with 3.1. 2011-03-16 11:35:38 +02:00
pymacro.h Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY() 2014-05-14 17:24:35 +02:00
pymath.h Issue #11495: OSF support is eliminated. It was deprecated in Python 3.2 2011-03-14 17:36:54 +01:00
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 Merged revisions 59541-59561 via svnmerge from 2007-12-19 02:07:34 +00:00
pystrhex.h Add the files missing from c9f1630cf2b1 for issue9951. 2015-04-26 00:41:00 +00:00
pystrtod.h Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
pythonrun.h PEP 479: Change StopIteration handling inside generators. 2015-05-09 11:44:30 -04:00
pythread.h Issue #11223: Replace threading._info() by sys.thread_info 2011-04-30 14:53:09 +02:00
pytime.h Issue #23834: Fix the default socket timeout 2015-04-09 10:23:12 +02:00
rangeobject.h #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. 2007-12-19 02:45:37 +00:00
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 s/tabs/spaces, and clean trailing whitespace 2012-05-23 07:09:08 +03:00
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 Issue #14785: Add sys._debugmallocstats() to help debug low-level memory allocation issues 2012-06-22 14:55:41 -04:00
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