cpython/Python
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
..
clinic Specify default values of semantic booleans in Argument Clinic generated signatures as booleans. 2015-05-30 11:30:39 +03:00
Python-ast.c PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
_warnings.c merge 3.4 (#24096) 2015-05-03 11:29:58 -04:00
asdl.c Issue #22207: Fix "comparison between signed and unsigned integers" warning in 2014-08-17 22:20:00 +02:00
ast.c PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
bltinmodule.c Specify default values of semantic booleans in Argument Clinic generated signatures as booleans. 2015-05-30 11:30:39 +03:00
ceval.c Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
ceval_gil.h Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
codecs.c Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(), 2015-05-30 17:48:19 +03:00
compile.c Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
condvar.h Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
dtoa.c Fix compiler warning in dtoa.c 2015-03-18 15:01:44 +01:00
dup2.c
dynamic_annotations.c
dynload_aix.c PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
dynload_dl.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_hpux.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_next.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_shlib.c PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
dynload_stub.c Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py. 2012-05-04 15:20:40 -04:00
dynload_win.c Issue #24268: Fixes generation of init import name on Windows. 2015-05-23 08:59:25 -07:00
errors.c Issue #22977: Fixed formatting Windows error messages on Wine. 2015-04-02 09:50:06 +03:00
fileutils.c Issue #23524: Replace _PyVerify_fd function with calls to _set_thread_local_invalid_parameter_handler. 2015-04-12 00:26:27 -04:00
formatter_unicode.c Close issue #8931: Make alternate formatting for 'c' raise an exception. Patch by Torsten Landschoff. 2014-04-15 22:37:55 -04:00
frozen.c Issue #23911: Move path-based bootstrap code to a separate frozen module. 2015-05-02 19:15:18 -06:00
frozenmain.c merge 3.4 (#22633) 2015-02-14 15:17:47 -05:00
future.c PEP 479: Change StopIteration handling inside generators. 2015-05-09 11:44:30 -04:00
getargs.c Fixed error message for the "u#" format code. 2015-04-19 21:13:00 +03:00
getcompiler.c
getcopyright.c merge 3.2 2014-12-31 18:10:13 -06:00
getopt.c #16306: report only the first unknown option and add more tests. Patch by Serhiy Storchaka. 2012-11-23 18:48:32 +02:00
getplatform.c
getversion.c
graminit.c allow test node after ** in calls (closes #24176) 2015-05-16 09:44:45 -04:00
import.c Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(), 2015-05-30 17:48:19 +03:00
importdl.c fix importing one char extension modules (closes #24328) 2015-05-29 17:10:30 -05:00
importdl.h PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
importlib.h PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
importlib_external.h Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
makeopcodetargets.py
marshal.c Issue #23752: _Py_fstat() is now responsible to raise the Python exception 2015-03-30 10:09:31 +02:00
modsupport.c Issue #20024: Py_BuildValue() now saves/restores the current exception before 2014-01-21 20:52:17 +01:00
mysnprintf.c
mystrtoul.c Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
opcode_targets.h Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
peephole.c PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
pyarena.c Issue #18203: Replace malloc() with PyMem_Malloc() to allocate arena objects 2013-07-07 17:18:53 +02:00
pyctype.c
pyfpe.c Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
pyhash.c Issue #20162: Fix an alignment issue in the siphash24() hash function which 2014-02-01 03:38:56 +01:00
pylifecycle.c Remove redundant check for tb != NULL to shut up Coverity . It has been set to Py_None a couple of lines earlier. 2015-04-16 17:25:45 +02:00
pymath.c Issue 24366: Indent code (thanks to li4ick for reporting). 2015-06-02 18:53:46 -04:00
pystate.c Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully 2015-06-02 18:43:51 -04:00
pystrcmp.c
pystrhex.c Silence a gcc "may be used uninitialized" compiler warning. Not true. 2015-04-25 23:51:39 -07:00
pystrtod.c Removed duplicated words in in comments and docs. 2014-12-01 18:28:43 +02:00
pythonrun.c Issue #23911: Move path-based bootstrap code to a separate frozen module. 2015-05-02 19:15:18 -06:00
pytime.c Issue #22117: Add a new _PyTime_FromSeconds() function 2015-04-03 13:10:54 +02:00
random.c (Merge 3.4) Issue #22585: os.urandom() now releases the GIL when the 2015-03-30 11:19:07 +02:00
sigcheck.c
strdup.c Issue #18722: Remove uses of the "register" keyword in C code. 2013-08-13 20:18:52 +02:00
structmember.c Fix null pointer dereferencing in structmember.c PyMember_SetOne() for T_CHAR. _PyUnicode_AsStringAndSize() can return NULL without touching the len argument. Also remove unnecessary PyUnicode_Check(), _PyUnicode_AsStringAndSize() performance the test again. CID 486815 2012-09-11 17:30:53 +02:00
symtable.c PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
sysmodule.c Issue 24017: Make PyEval_(Set|Get)CoroutineWrapper private 2015-06-01 12:15:23 -04:00
thread.c Removed duplicated words in in comments and docs. 2014-12-01 18:30:14 +02:00
thread_foobar.h Issue #21312: Update the thread_foobar.h template file to include newer threading APIs. Patch by Jack McCracken. 2014-04-28 21:12:11 +02:00
thread_nt.h Merging from 3.3: The PyCOND_TIMEDWAIT must use microseconds for the timeout argument 2014-05-08 10:59:52 +00:00
thread_pthread.h Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and 2014-08-17 22:11:06 +02:00
traceback.c Issue #24436: Added const qualifiers for char* arguments of _PyTraceback_Add. 2015-06-21 16:00:33 +03:00

README

Miscellaneous source files for the main Python shared library