Commit Graph

202 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
Yury Selivanov 4180e43c12 Docs: Fix typo 2015-06-04 11:10:24 -04:00
Yury Selivanov aab3c4a211 Issue 24342: Let wrapper set by sys.set_coroutine_wrapper fail gracefully 2015-06-02 18:43:51 -04:00
Yury Selivanov d4cbbebe2d Issue 24180: Document sys.(set|get)_coroutine_wrapper 2015-05-31 17:13:08 -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
Antoine Pitrou 5db1bb81ff Issue #22696: Add function :func:`sys.is_finalizing` to know about interpreter shutdown. 2014-12-07 01:28:27 +01:00
Georg Brandl 93a56cdc37 Doc: fix default role usage (except in unittest mock docs) 2014-10-30 22:25:41 +01:00
Berker Peksag 9c1dba2758 Revert #22251 2014-09-28 00:00:58 +03:00
Berker Peksag 3749404ba5 Issue #22251: Fix ReST markup to avoid errors building docs. 2014-09-27 23:21:35 +03:00
Antoine Pitrou 2d1ec06484 Issue #21364: remove recommendation of broken pattern. 2014-05-15 22:38:56 +02:00
Georg Brandl df48b97855 Fix a few scoping issues with versionadded/versionchanged directives. 2014-03-24 09:06:18 +01:00
R David Murray f93d3dfc50 closes #20960 2014-03-17 11:20:29 -04:00
Larry Hastings 3732ed2414 Merge in all documentation changes since branching 3.4.0rc1. 2014-03-15 21:13:56 -07:00
Serhiy Storchaka 2a6145290b Removed spaces before commas and periods. 2013-12-23 18:21:57 +02:00
Serhiy Storchaka a4d170d985 Removed spaces before commas and periods. 2013-12-23 18:20:51 +02:00
Victor Stinner 5f5657ee50 (Merge 3.3) Issue #19728: Fix sys.getfilesystemencoding() documentation 2013-12-02 12:17:29 +01:00
Victor Stinner 22d0418f71 Issue #19728: Fix sys.getfilesystemencoding() documentation 2013-12-02 12:16:46 +01:00
Serhiy Storchaka 0e90e99188 Issue #19795: Improved markup of True/False constants. 2013-11-29 12:19:53 +02:00
Serhiy Storchaka fbc1c26803 Issue #19795: Improved markup of True/False constants. 2013-11-29 12:17:13 +02:00
Christian Heimes 985ecdcfc2 ssue #19183: Implement PEP 456 'secure and interchangeable hash algorithm'.
Python now uses SipHash24 on all major platforms.
2013-11-20 11:46:18 +01:00
Andrew Kuchling c61b913078 #13226: update references from ctypes/DLFCN modules to os module 2013-06-21 10:58:41 -04:00
Brett Cannon c3511c1dd8 Issue #17953: document that sys.modules shouldn't be replaced (thanks
to interp->modules) and that deleting essential items from the dict
can cause Python to blow up.

Thanks to Terry Reedy for coming up with initial wording and Yogesh
Chaudhari for coming up with a patch using that wording in parallel to
my own patch.
2013-05-24 08:05:07 -04:00
Brett Cannon 6489d0b380 merge fix for issue #17953 2013-05-24 17:31:37 -04:00
Antoine Pitrou 1a6cb30a34 Issue #5845: Enable tab-completion in the interactive interpreter by default, thanks to a new sys.__interactivehook__.
(original patch by Éric Araujo)
2013-05-04 20:08:35 +02:00
Georg Brandl 1bab7134a8 Merge with 3.3. 2013-03-28 13:28:55 +01:00
Georg Brandl 44ea77bd81 Closes #4159: add LaTeX tabular column specifications to tables that otherwise are cut off or have overlapping text. 2013-03-28 13:28:44 +01:00
Brett Cannon 115309acec Issue #17176: Document that imp.NullImporter is no longer
automatically used by import.
2013-03-13 10:58:50 -07:00
Brett Cannon 2514b4871f Issue #17176: Document that imp.NullImporter is no longer inserted
into sys.path_importer_cache.
2013-03-13 10:46:22 -07:00
Nick Coghlan 90c91afd2e Merge fix for #15465 from 3.3 2013-03-07 23:45:03 +10:00
Nick Coghlan 7d82c8621b Close #15465: Document C API version macros
Mostly moving the existing macro docs over from the standard
library docs to the C API docs where they belong.

Patch by Kushal Das.
2013-03-07 23:14:44 +10:00
Benjamin Peterson 184f01544f merge 3.3 (#7340) 2013-01-15 16:49:35 -05:00
Benjamin Peterson 0ad344a832 remove warning about tb circular reference (closes #7340) 2013-01-15 16:49:22 -05:00
Antoine Pitrou 928405303d Following issue #13390, fix compilation --without-pymalloc, and make sys.getallocatedblocks() return 0 in that situation. 2012-12-17 23:05:59 +01:00
Antoine Pitrou f9d0b1256f Issue #13390: New function :func:`sys.getallocatedblocks()` returns the number of memory blocks currently allocated.
Also, the ``-R`` option to regrtest uses this function to guard against memory allocation leaks.
2012-12-09 14:28:26 +01:00
Éric Araujo bb7da03f6e Merge fixes for #13614, #13512 and #7719 from 3.3 2012-12-08 22:57:08 -05:00
Éric Araujo 3f7c0e4036 Merge fixes for #13614, #13512 and #7719 from 3.2 2012-12-08 22:53:43 -05:00
Éric Araujo 9bc9ab5f85 Fix a few markup/grammar nits 2012-12-08 18:35:31 -05:00
Barry Warsaw b72c10996e - Issue #16514: Fix regression causing a traceback when sys.path[0] is None
(actually, any non-string or non-bytes type).
2012-11-20 15:35:27 -05:00
Barry Warsaw 82c1c781c7 - Issue #16514: Fix regression causing a traceback when sys.path[0] is None
(actually, any non-string or non-bytes type).
2012-11-20 15:22:51 -05:00
Jesus Cea f6c2e894ae #16135: Removal of OS/2 support (Docs) 2012-10-05 01:11:10 +02:00
Vinay Sajip cd9b746b37 Added cross-references to venv definition. 2012-07-09 10:37:01 +01:00
David Malcolm 49526f48fc Issue #14785: Add sys._debugmallocstats() to help debug low-level memory allocation issues 2012-06-22 14:55:41 -04:00
Martin v. Löwis 1e5d0ff8a0 Elaborate that sizeof only accounts for the object itself. 2012-06-17 10:40:16 +02:00
Barry Warsaw 9b10e1fbb9 A few documentation improvements, spurred on by Brett's review. 2012-06-04 11:06:45 -04:00
Barry Warsaw 409da157d7 Eric Snow's implementation of PEP 421.
Issue 14673: Add sys.implementation
2012-06-03 16:18:47 -04:00
Georg Brandl 039b01d015 Add missing versionadded. 2012-05-26 09:11:22 +02:00
Vinay Sajip 7ded1f0f69 Implemented PEP 405 (Python virtual environments). 2012-05-26 03:45:29 +01:00
Georg Brandl a673eb895e Fix invalid markup and update suspicious ignores. 2012-03-04 16:17:05 +01:00
Georg Brandl 335d628a66 merge with 3.2 2012-02-23 21:17:27 +01:00
Georg Brandl eb25fb7af7 Fix markup errors. 2012-02-23 21:12:39 +01:00