Commit graph

74 commits

Author SHA1 Message Date
Serhiy Storchaka
ecf41da83e Issue #19795: Mark up None as literal text. 2016-10-19 16:29:26 +03:00
Serhiy Storchaka
585c93daea Issue #26733: Disassembling a class now disassembles class and static methods.
Patch by Xiang Zhang.
2016-04-23 09:23:52 +03:00
Martin Panter
cc71a795df Fix typos in documentation and comments 2016-04-05 06:19:42 +00:00
Antoine Pitrou
5e8d47f6ab Issue #16554: fix description for MAKE_CLOSURE. Initial patch by Daniel Urban. 2015-08-13 20:37:28 +02:00
Antoine Pitrou
4ce4f974da Issue #16554: fix description for MAKE_CLOSURE. Initial patch by Daniel Urban. 2015-08-13 20:37:08 +02:00
Yury Selivanov
66f8828bfc Issue #24439: Improve PEP 492 related docs.
Patch by Martin Panter.
2015-06-24 11:04:15 -04:00
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
Benjamin Peterson
264be6f48f remove STORE_MAP, since it's unused 2015-05-28 14:40:08 -05:00
Yury Selivanov
7544508f02 PEP 0492 -- Coroutines with async and await syntax. Issue #24017. 2015-05-11 22:57:16 -04:00
Berker Peksag
da0870c87a Add versionadded directives for the matmul operator. 2015-03-12 20:56:45 +02:00
Benjamin Peterson
2f3d440549 merge 3.4 (#23561) 2015-03-02 09:36:48 -05:00
Benjamin Peterson
bdf525b77c wrap everything at 80 chars 2015-03-02 09:31:40 -05:00
Benjamin Peterson
29fec92875 link to the correct dis method or function (closes #23561) 2015-03-02 09:27:43 -05:00
Berker Peksag
6897e5688d Issue #20521: Change `TOS` to TOS in dis documentation.
TOS is an abbreviation of top-of-stack.

Patch by Sven Berkvens-Matthijsse.
2015-03-02 06:34:00 +02:00
Berker Peksag
ab4040e3c6 Issue #20521: Change `TOS` to TOS in dis documentation.
TOS is an abbreviation of top-of-stack.

Patch by Sven Berkvens-Matthijsse.
2015-03-02 06:33:30 +02:00
Serhiy Storchaka
f4f314ba3f Issue #22845: Improved formatting of dis documentation. 2014-11-11 10:02:46 +02:00
Serhiy Storchaka
f751a9e6a2 Issue #22845: Improved formatting of dis documentation. 2014-11-11 10:02:11 +02:00
Nick Coghlan
efd5df9e52 Issue #21947: handle generator-iterator objects in dis
Patch by Clement Rouault.
2014-07-25 23:02:56 +10:00
Benjamin Peterson
d51374ed78 PEP 465: a dedicated infix operator for matrix multiplication (closes #21176) 2014-04-09 23:55:56 -04:00
R David Murray
0bce6e7462 whatsnew: expand 'dis' entry.
Also add one missing versionadded.
2014-01-07 14:30:17 -05:00
Serhiy Storchaka
0e90e99188 Issue #19795: Improved markup of True/False constants. 2013-11-29 12:19:53 +02:00
Larry Hastings
3a9079742f Issue #19722: Added opcode.stack_effect(), which accurately
computes the stack effect of bytecode instructions.
2013-11-23 14:49:22 -08:00
Nick Coghlan
50c48b89e3 Close #17916: dis.Bytecode based replacement for distb
- Bytecode.from_traceback() alternate constructor
- current_offset parameter and attribute

Patch by Claudiu Popa
2013-11-23 00:57:00 +10:00
Nick Coghlan
07155c9c14 Fix typo in updated dis docs 2013-11-06 22:12:07 +10:00
Nick Coghlan
90b8e7d2bc Close #19378: address flaws in the new dis module APIs
- confusing line_offset parameter -> first_line parameter
- systematically test and fix new file parameter
- remove redundant Bytecode.show_info() API
- rename Bytecode.display_code() to Bytecode.dis() and have it
  return the multi-line string rather than printing it directly
- eliminated some not-so-helpful helpers from the bytecode_helper
  test support module

Also fixed a longstanding defect (worked around in the test suite)
where lines emitted by the dis module could include trailing white
space. That no longer happens, allowing the formatting tests to be
simplified to use plain string comparisons.
2013-11-06 22:08:36 +10:00
Georg Brandl
3cb26b77b6 merge with 3.3 2013-10-12 18:41:23 +02:00
Georg Brandl
c96ef1f0ed Closes #13026: fix documentation of MAKE_FUNCTION for 3.x. 2013-10-12 18:41:18 +02:00
Ezio Melotti
6e6c6ac3d7 #18796: improve documentation of the file argument of dis.show_code. Initial patch by Vajrasky Kok. 2013-08-23 22:41:39 +03:00
Benjamin Peterson
e8e14591eb rather than passing locals to the class body, just execute the class body in the proper environment 2013-05-16 14:37:25 -05:00
Nick Coghlan
b39fd0c9b8 Issue #11816: multiple improvements to the dis module
* get_instructions generator
* ability to redirect output to a file
* Bytecode and Instruction abstractions

Patch by Nick Coghlan, Ryan Kelly and Thomas Kluyver.
2013-05-06 23:59:20 +10:00
Benjamin Peterson
3b0431dc60 check local class namespace before reaching for cells (closes #17853) 2013-04-30 09:41:40 -04:00
Andrew Svetlov
a5c430940c Issue #16538: correctly describe MAKE_CLOSURE in docs.
Patch by Daniel Urban
2012-11-23 15:28:34 +02:00
Benjamin Peterson
143d034ecd merge 3.2 2012-10-12 12:04:32 -04:00
Ezio Melotti
7fa822275b Fix links to the __next__ method. 2012-10-12 13:42:08 +03:00
Eli Bendersky
60ee04969e Issue #14349: Fix the doc of the MAKE_FUNCTION opcode in Doc/library/dis.rst to
correctly list the stack params it expects.
2012-03-24 18:52:45 +02:00
Nick Coghlan
1f7ce62bd6 Implement PEP 380 - 'yield from' (closes #11682) 2012-01-13 21:43:40 +10:00
Benjamin Peterson
76f7f4d979 excise the remains of STOP_CODE, which hasn't done anything useful for years 2011-07-17 22:49:50 -05:00
Raymond Hettinger
4f707fd316 Separate source link from main text. 2011-01-10 19:54:11 +00:00
Raymond Hettinger
1048094037 Move source links to consistent location and remove wordy, big yellow boxes. 2011-01-10 03:26:08 +00:00
Antoine Pitrou
c58bde159f SET_LINENO was removed in 2.3 2010-12-12 18:09:53 +00:00
Éric Araujo
6e6cb8e0e4 Provide links to Python source where the code is short, readable and
informative adjunct to the docs.  Forward-port of Raymond's r86225 and
r86245 using the new source reST role added in #10334.
2010-11-16 19:13:50 +00:00
Georg Brandl
2379877246 Fix documentation of dis.opmap direction. 2010-10-17 11:29:07 +00:00
Amaury Forgeot d'Arc
ba117ef7e9 #4617: Previously it was illegal to delete a name from the local
namespace if it occurs as a free variable in a nested block.  This limitation
of the compiler has been lifted, and a new opcode introduced (DELETE_DEREF).

This sample was valid in 2.6, but fails to compile in 3.x without this change::

   >>> def f():
   ...     def print_error():
   ...        print(e)
   ...     try:
   ...        something
   ...     except Exception as e:
   ...        print_error()
   ...        # implicit "del e" here


This sample has always been invalid in Python, and now works::

   >>> def outer(x):
   ...     def inner():
   ...        return x
   ...     inner()
   ...     del x

There is no need to bump the PYC magic number: the new opcode is used
for code that did not compile before.
2010-09-10 21:39:53 +00:00
Nick Coghlan
e8814fbb32 As per python-dev discussion with Eli, properly document and publish dis.show_code 2010-09-10 14:08:04 +00:00
Antoine Pitrou
74a69fa662 Issue #9225: Remove the ROT_FOUR and DUP_TOPX opcode, the latter replaced
by the new (and simpler) DUP_TOP_TWO.  Performance isn't changed, but
our bytecode is a bit simplified.  Patch by Demur Rumed.
2010-09-04 18:43:52 +00:00
Georg Brandl
67b21b7547 Consistency check for versionadded/changed directives. 2010-08-17 15:07:14 +00:00
Nick Coghlan
eae2da1da7 Issue 9147: Add dis.code_info() 2010-08-17 08:03:36 +00:00
Georg Brandl
4833e5b874 Remove the need for a "()" empty argument list after opcodes. 2010-07-03 10:41:33 +00:00
Georg Brandl
19b7a87121 Wrap and use the correct directive. 2010-07-03 10:21:50 +00:00
Nick Coghlan
5c8b54eb04 Issue 6507: accept source strings directly in dis.dis(). Original patch by Daniel Urban 2010-07-03 07:36:51 +00:00