Commit graph

519 commits

Author SHA1 Message Date
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
Terry Jan Reedy
bd44ce8ead Merge with 3.4 2015-06-12 15:45:05 -04:00
Terry Jan Reedy
f5d4523844 Closes issue #24405: mark set display as code. 2015-06-12 15:44:45 -04:00
Raymond Hettinger
ab89f9c27f merge 2015-05-22 16:38:16 -07:00
Raymond Hettinger
9ecf9e2944 Issue #24219: Remove duplicate literal in docs. 2015-05-22 16:37:49 -07:00
Yury Selivanov
f3e40fac10 Issue 24180: Documentation for PEP 492 changes. 2015-05-21 11:50:30 -04:00
Yury Selivanov
8170e8c0d1 PEP 479: Change StopIteration handling inside generators.
Closes issue #22906.
2015-05-09 11:44:30 -04:00
Guido van Rossum
19dac071ef Issue 24088: Clarify semantics of yield expression (merge from 3.4). 2015-05-05 12:04:35 -07:00
Guido van Rossum
d0150ad59e Issue 24088: Clarify semantics of yield expression. 2015-05-05 12:02:01 -07:00
Benjamin Peterson
51f58059f6 merge 3.4 (#24049) 2015-04-24 12:02:53 -04:00
Benjamin Peterson
9bdd61338d remove dead *-import checking code (closes #24049) 2015-04-24 12:02:29 -04:00
Barry Warsaw
b5a3d9bebb Issue #24029: Document the name binding behavior for submodule imports. 2015-04-22 18:38:26 -04:00
Barry Warsaw
2097f53ec3 Issue #24029: Document the name binding behavior for submodule imports. 2015-04-22 18:29:16 -04:00
Brett Cannon
f299abdafa Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
2015-04-13 14:21:02 -04:00
Berker Peksag
770319d6bd Issue #23912: Fix code formatting in datamodel.rst.
Patch by James Edwards.
2015-04-11 14:59:30 +03:00
Berker Peksag
2995cc6855 Issue #23912: Fix code formatting in datamodel.rst.
Patch by James Edwards.
2015-04-11 14:59:50 +03:00
Zachary Ware
4785f5e249 Merge with 3.4 2015-02-19 22:15:54 -06:00
Zachary Ware
57c616f1e4 Fix a typo pointed out on docs@ 2015-02-19 22:15:36 -06:00
Ethan Furman
e62430eda4 Issue22988: clarify yield and exception blocks 2015-01-14 22:26:04 -08:00
Ethan Furman
2f825af728 Issue22988: clarify yield and exception blocks 2015-01-14 22:25:27 -08:00
Ethan Furman
9fdb0fe17b Issue20467: clarify __init__'s role 2015-01-14 21:57:15 -08:00
Ethan Furman
845d33c526 Issue20467: clarify __init__'s role 2015-01-14 21:56:49 -08:00
Ethan Furman
119479f705 Issue20467: clarify __init__'s role 2015-01-14 21:56:10 -08:00
Brett Cannon
02d8454002 Issue #23014: Make importlib.abc.Loader.create_module() required when
importlib.abc.Loader.exec_module() is also defined.

Before this change, create_module() was optional **and** could return
None to trigger default semantics. This change now reduces the
options for choosing default semantics to one and in the most
backporting-friendly way (define create_module() to return None).
2015-01-09 11:39:21 -05:00
Terry Jan Reedy
b67f6e27e1 Issue #23006: Improve the documentation and indexing of dict.__missing__.
Add an entry in the language datamodel special methods section.
Revise and index its discussion in the stdtypes mapping/dict section.
2014-12-10 18:38:19 -05:00
R David Murray
c9f5f2ddc7 #22918: Drop obsolete mention of 'keys' in datamodel __iter__ docs.
Patch by Chaitanya Agrawal.
2014-12-10 09:51:01 -05:00
Ethan Furman
b004943e9b (3.4) Issue22780: reword NotImplemented docs to emphasise should 2014-11-26 21:15:35 -08:00
Terry Jan Reedy
e6b2b78a7d Merge 3.4 2014-12-10 18:39:45 -05:00
R David Murray
892dbd18e1 Merge: #22918: Drop obsolete mention of 'keys' in datamodel __iter__ docs. 2014-12-10 09:51:27 -05:00
Ethan Furman
9b55089999 Issue22780: reword NotImplemented docs to emphasise should 2014-11-26 21:17:53 -08:00
Brett Cannon
b6e2556d8f Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists.

Thanks to Martin Panter for the bug report.
2014-11-21 12:19:28 -05:00
Brett Cannon
d0c4ef175b Issue #22242: Try to make some import-related loader details clearer.
Thanks to Jon Poler for pointing this out.
2014-11-07 11:29:33 -05:00
Georg Brandl
e21a531ef1 merge with 3.4 2014-10-31 10:39:29 +01:00
Georg Brandl
a4c8c47961 #22613: remaining corrections in extending/reference docs (thanks Jacques Ducasse) 2014-10-31 10:38:49 +01:00
Georg Brandl
794e9bf1fe merge with 3.4 2014-10-29 10:27:06 +01:00
Georg Brandl
525d355984 Fixing broken links in doc, part 3: the rest 2014-10-29 10:26:56 +01:00
Georg Brandl
cadc3fdcb5 Merge with 3.4 2014-10-29 08:37:29 +01:00
Georg Brandl
e73778c1ac Use https:// URLs when referring to python.org hosts. 2014-10-29 08:36:35 +01:00
Ethan Furman
58b2ddf392 Issue7186: document that __doc__ is not inherited by subclasses 2014-10-17 22:25:47 -07:00
Ethan Furman
f87f515057 Issue7186: document that __doc__ is not inherited by subclasses 2014-10-17 22:25:22 -07:00
R David Murray
2623a5db6f Merge: #18176: Change generic UCD PropList link to version specific link. 2014-10-09 20:47:31 -04:00
R David Murray
5f16f90d1b #18176: Change generic UCD PropList link to version specific link. 2014-10-09 20:45:59 -04:00
R David Murray
532783bd5e Merge: #18176: fix another reference and add it to the makeunicodedata comment. 2014-10-09 17:41:55 -04:00
R David Murray
5bd62420f4 #18176: fix another reference and add it to the makeunicodedata comment. 2014-10-09 17:39:48 -04:00
Terry Jan Reedy
cd09571894 Merge with 3.4 2014-09-30 19:08:02 -04:00
Terry Jan Reedy
b6271f2d2b Issue 22465: grammar, number agreement. 2014-09-30 19:07:49 -04:00
Serhiy Storchaka
1aca6e1a91 Issue #20643: Removed unneeded (and wrong) class directives. 2014-09-05 23:28:19 +03:00
Serhiy Storchaka
848c8b29f6 Issue #20643: Removed unneeded (and wrong) class directives. 2014-09-05 23:27:36 +03:00
Terry Jan Reedy
523136937f Merge with 3.4 2014-08-23 19:29:58 -04:00
Terry Jan Reedy
65e3ecb3e2 Issue #22243: fix except grammar in reference. 2014-08-23 19:29:47 -04:00