cpython/Doc/library/dis.rst

821 lines
19 KiB
ReStructuredText
Raw Normal View History

2007-08-15 11:28:01 -03:00
:mod:`dis` --- Disassembler for Python bytecode
===============================================
2007-08-15 11:28:01 -03:00
.. module:: dis
:synopsis: Disassembler for Python bytecode.
2007-08-15 11:28:01 -03:00
The :mod:`dis` module supports the analysis of Python :term:`bytecode` by disassembling
2007-08-15 11:28:01 -03:00
it. Since there is no Python assembler, this module defines the Python assembly
language. The Python bytecode which this module takes as an input is defined
2007-08-15 11:28:01 -03:00
in the file :file:`Include/opcode.h` and used by the compiler and the
interpreter.
Example: Given the function :func:`myfunc`::
def myfunc(alist):
return len(alist)
the following command can be used to get the disassembly of :func:`myfunc`::
>>> dis.dis(myfunc)
2 0 LOAD_GLOBAL 0 (len)
3 LOAD_FAST 0 (alist)
6 CALL_FUNCTION 1
9 RETURN_VALUE
(The "2" is a line number).
The :mod:`dis` module defines the following functions and constants:
.. function:: dis([bytesource])
Disassemble the *bytesource* object. *bytesource* can denote either a module, a
class, a method, a function, or a code object. For a module, it disassembles
all functions. For a class, it disassembles all methods. For a single code
sequence, it prints one line per bytecode instruction. If no object is
2007-08-15 11:28:01 -03:00
provided, it disassembles the last traceback.
.. function:: distb([tb])
Disassembles the top-of-stack function of a traceback, using the last traceback
if none was passed. The instruction causing the exception is indicated.
.. function:: disassemble(code[, lasti])
Disassembles a code object, indicating the last instruction if *lasti* was
provided. The output is divided in the following columns:
#. the line number, for the first instruction of each line
#. the current instruction, indicated as ``-->``,
#. a labelled instruction, indicated with ``>>``,
#. the address of the instruction,
#. the operation code name,
#. operation parameters, and
#. interpretation of the parameters in parentheses.
The parameter interpretation recognizes local and global variable names,
constant values, branch targets, and compare operators.
.. function:: disco(code[, lasti])
A synonym for disassemble. It is more convenient to type, and kept for
compatibility with earlier Python releases.
.. data:: opname
Sequence of operation names, indexable using the bytecode.
2007-08-15 11:28:01 -03:00
.. data:: opmap
Dictionary mapping bytecodes to operation names.
2007-08-15 11:28:01 -03:00
.. data:: cmp_op
Sequence of all compare operation names.
.. data:: hasconst
Sequence of bytecodes that have a constant parameter.
2007-08-15 11:28:01 -03:00
.. data:: hasfree
Sequence of bytecodes that access a free variable.
2007-08-15 11:28:01 -03:00
.. data:: hasname
Sequence of bytecodes that access an attribute by name.
2007-08-15 11:28:01 -03:00
.. data:: hasjrel
Sequence of bytecodes that have a relative jump target.
2007-08-15 11:28:01 -03:00
.. data:: hasjabs
Sequence of bytecodes that have an absolute jump target.
2007-08-15 11:28:01 -03:00
.. data:: haslocal
Sequence of bytecodes that access a local variable.
2007-08-15 11:28:01 -03:00
.. data:: hascompare
Sequence of bytecodes of Boolean operations.
2007-08-15 11:28:01 -03:00
.. _bytecodes:
Python Bytecode Instructions
----------------------------
2007-08-15 11:28:01 -03:00
The Python compiler currently generates the following bytecode instructions.
2007-08-15 11:28:01 -03:00
.. opcode:: STOP_CODE ()
Indicates end-of-code to the compiler, not used by the interpreter.
.. opcode:: NOP ()
Do nothing code. Used as a placeholder by the bytecode optimizer.
.. opcode:: POP_TOP ()
Removes the top-of-stack (TOS) item.
.. opcode:: ROT_TWO ()
Swaps the two top-most stack items.
.. opcode:: ROT_THREE ()
Lifts second and third stack item one position up, moves top down to position
three.
.. opcode:: ROT_FOUR ()
Lifts second, third and forth stack item one position up, moves top down to
position four.
.. opcode:: DUP_TOP ()
Duplicates the reference on top of the stack.
Unary Operations take the top of the stack, apply the operation, and push the
result back on the stack.
.. opcode:: UNARY_POSITIVE ()
Implements ``TOS = +TOS``.
.. opcode:: UNARY_NEGATIVE ()
Implements ``TOS = -TOS``.
.. opcode:: UNARY_NOT ()
Implements ``TOS = not TOS``.
.. opcode:: UNARY_CONVERT ()
Implements ``TOS = `TOS```.
.. opcode:: UNARY_INVERT ()
Implements ``TOS = ~TOS``.
.. opcode:: GET_ITER ()
Implements ``TOS = iter(TOS)``.
Binary operations remove the top of the stack (TOS) and the second top-most
stack item (TOS1) from the stack. They perform the operation, and put the
result back on the stack.
.. opcode:: BINARY_POWER ()
Implements ``TOS = TOS1 ** TOS``.
.. opcode:: BINARY_MULTIPLY ()
Implements ``TOS = TOS1 * TOS``.
.. opcode:: BINARY_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is not
in effect.
.. opcode:: BINARY_FLOOR_DIVIDE ()
Implements ``TOS = TOS1 // TOS``.
.. opcode:: BINARY_TRUE_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is in
effect.
.. opcode:: BINARY_MODULO ()
Implements ``TOS = TOS1 % TOS``.
.. opcode:: BINARY_ADD ()
Implements ``TOS = TOS1 + TOS``.
.. opcode:: BINARY_SUBTRACT ()
Implements ``TOS = TOS1 - TOS``.
.. opcode:: BINARY_SUBSCR ()
Implements ``TOS = TOS1[TOS]``.
.. opcode:: BINARY_LSHIFT ()
Implements ``TOS = TOS1 << TOS``.
.. opcode:: BINARY_RSHIFT ()
Implements ``TOS = TOS1 >> TOS``.
.. opcode:: BINARY_AND ()
Implements ``TOS = TOS1 & TOS``.
.. opcode:: BINARY_XOR ()
Implements ``TOS = TOS1 ^ TOS``.
.. opcode:: BINARY_OR ()
Implements ``TOS = TOS1 | TOS``.
In-place operations are like binary operations, in that they remove TOS and
TOS1, and push the result back on the stack, but the operation is done in-place
when TOS1 supports it, and the resulting TOS may be (but does not have to be)
the original TOS1.
.. opcode:: INPLACE_POWER ()
Implements in-place ``TOS = TOS1 ** TOS``.
.. opcode:: INPLACE_MULTIPLY ()
Implements in-place ``TOS = TOS1 * TOS``.
.. opcode:: INPLACE_DIVIDE ()
Implements in-place ``TOS = TOS1 / TOS`` when ``from __future__ import
division`` is not in effect.
.. opcode:: INPLACE_FLOOR_DIVIDE ()
Implements in-place ``TOS = TOS1 // TOS``.
.. opcode:: INPLACE_TRUE_DIVIDE ()
Implements in-place ``TOS = TOS1 / TOS`` when ``from __future__ import
division`` is in effect.
.. opcode:: INPLACE_MODULO ()
Implements in-place ``TOS = TOS1 % TOS``.
.. opcode:: INPLACE_ADD ()
Implements in-place ``TOS = TOS1 + TOS``.
.. opcode:: INPLACE_SUBTRACT ()
Implements in-place ``TOS = TOS1 - TOS``.
.. opcode:: INPLACE_LSHIFT ()
Implements in-place ``TOS = TOS1 << TOS``.
.. opcode:: INPLACE_RSHIFT ()
Implements in-place ``TOS = TOS1 >> TOS``.
.. opcode:: INPLACE_AND ()
Implements in-place ``TOS = TOS1 & TOS``.
.. opcode:: INPLACE_XOR ()
Implements in-place ``TOS = TOS1 ^ TOS``.
.. opcode:: INPLACE_OR ()
Implements in-place ``TOS = TOS1 | TOS``.
The slice opcodes take up to three parameters.
.. opcode:: SLICE+0 ()
Implements ``TOS = TOS[:]``.
.. opcode:: SLICE+1 ()
Implements ``TOS = TOS1[TOS:]``.
.. opcode:: SLICE+2 ()
Implements ``TOS = TOS1[:TOS]``.
.. opcode:: SLICE+3 ()
Implements ``TOS = TOS2[TOS1:TOS]``.
Slice assignment needs even an additional parameter. As any statement, they put
nothing on the stack.
.. opcode:: STORE_SLICE+0 ()
Implements ``TOS[:] = TOS1``.
.. opcode:: STORE_SLICE+1 ()
Implements ``TOS1[TOS:] = TOS2``.
.. opcode:: STORE_SLICE+2 ()
Implements ``TOS1[:TOS] = TOS2``.
.. opcode:: STORE_SLICE+3 ()
Implements ``TOS2[TOS1:TOS] = TOS3``.
.. opcode:: DELETE_SLICE+0 ()
Implements ``del TOS[:]``.
.. opcode:: DELETE_SLICE+1 ()
Implements ``del TOS1[TOS:]``.
.. opcode:: DELETE_SLICE+2 ()
Implements ``del TOS1[:TOS]``.
.. opcode:: DELETE_SLICE+3 ()
Implements ``del TOS2[TOS1:TOS]``.
.. opcode:: STORE_SUBSCR ()
Implements ``TOS1[TOS] = TOS2``.
.. opcode:: DELETE_SUBSCR ()
Implements ``del TOS1[TOS]``.
Miscellaneous opcodes.
.. opcode:: PRINT_EXPR ()
Implements the expression statement for the interactive mode. TOS is removed
from the stack and printed. In non-interactive mode, an expression statement is
terminated with ``POP_STACK``.
.. opcode:: PRINT_ITEM ()
Prints TOS to the file-like object bound to ``sys.stdout``. There is one such
instruction for each item in the :keyword:`print` statement.
.. opcode:: PRINT_ITEM_TO ()
Like ``PRINT_ITEM``, but prints the item second from TOS to the file-like object
at TOS. This is used by the extended print statement.
.. opcode:: PRINT_NEWLINE ()
Prints a new line on ``sys.stdout``. This is generated as the last operation of
a :keyword:`print` statement, unless the statement ends with a comma.
.. opcode:: PRINT_NEWLINE_TO ()
Like ``PRINT_NEWLINE``, but prints the new line on the file-like object on the
TOS. This is used by the extended print statement.
.. opcode:: BREAK_LOOP ()
Terminates a loop due to a :keyword:`break` statement.
.. opcode:: CONTINUE_LOOP (target)
Continues a loop due to a :keyword:`continue` statement. *target* is the
address to jump to (which should be a ``FOR_ITER`` instruction).
.. opcode:: LIST_APPEND ()
Calls ``list.append(TOS1, TOS)``. Used to implement list comprehensions.
.. opcode:: LOAD_LOCALS ()
Pushes a reference to the locals of the current scope on the stack. This is used
in the code for a class definition: After the class body is evaluated, the
locals are passed to the class definition.
.. opcode:: RETURN_VALUE ()
Returns with TOS to the caller of the function.
.. opcode:: YIELD_VALUE ()
2007-10-21 07:52:38 -03:00
Pops ``TOS`` and yields it from a :term:`generator`.
2007-08-15 11:28:01 -03:00
.. opcode:: IMPORT_STAR ()
Loads all symbols not starting with ``'_'`` directly from the module TOS to the
local namespace. The module is popped after loading all names. This opcode
implements ``from module import *``.
.. opcode:: EXEC_STMT ()
Implements ``exec TOS2,TOS1,TOS``. The compiler fills missing optional
parameters with ``None``.
.. opcode:: POP_BLOCK ()
Removes one block from the block stack. Per frame, there is a stack of blocks,
denoting nested loops, try statements, and such.
.. opcode:: END_FINALLY ()
Terminates a :keyword:`finally` clause. The interpreter recalls whether the
exception has to be re-raised, or whether the function returns, and continues
with the outer-next block.
.. opcode:: BUILD_CLASS ()
Creates a new class object. TOS is the methods dictionary, TOS1 the tuple of
the names of the base classes, and TOS2 the class name.
.. opcode:: WITH_CLEANUP ()
Cleans up the stack when a :keyword:`with` statement block exits. On top of
the stack are 1--3 values indicating how/why the finally clause was entered:
* TOP = ``None``
* (TOP, SECOND) = (``WHY_{RETURN,CONTINUE}``), retval
* TOP = ``WHY_*``; no retval below it
* (TOP, SECOND, THIRD) = exc_info()
Under them is EXIT, the context manager's :meth:`__exit__` bound method.
In the last case, ``EXIT(TOP, SECOND, THIRD)`` is called, otherwise
``EXIT(None, None, None)``.
EXIT is removed from the stack, leaving the values above it in the same
order. In addition, if the stack represents an exception, *and* the function
call returns a 'true' value, this information is "zapped", to prevent
``END_FINALLY`` from re-raising the exception. (But non-local gotos should
still be resumed.)
.. XXX explain the WHY stuff!
2007-08-15 11:28:01 -03:00
All of the following opcodes expect arguments. An argument is two bytes, with
the more significant byte last.
.. opcode:: STORE_NAME (namei)
Implements ``name = TOS``. *namei* is the index of *name* in the attribute
2008-02-23 11:43:48 -04:00
:attr:`co_names` of the code object. The compiler tries to use ``STORE_FAST``
2007-08-15 11:28:01 -03:00
or ``STORE_GLOBAL`` if possible.
.. opcode:: DELETE_NAME (namei)
Implements ``del name``, where *namei* is the index into :attr:`co_names`
attribute of the code object.
.. opcode:: UNPACK_SEQUENCE (count)
Unpacks TOS into *count* individual values, which are put onto the stack
right-to-left.
.. opcode:: DUP_TOPX (count)
Duplicate *count* items, keeping them in the same order. Due to implementation
limits, *count* should be between 1 and 5 inclusive.
.. opcode:: STORE_ATTR (namei)
Implements ``TOS.name = TOS1``, where *namei* is the index of name in
:attr:`co_names`.
.. opcode:: DELETE_ATTR (namei)
Implements ``del TOS.name``, using *namei* as index into :attr:`co_names`.
.. opcode:: STORE_GLOBAL (namei)
Works as ``STORE_NAME``, but stores the name as a global.
.. opcode:: DELETE_GLOBAL (namei)
Works as ``DELETE_NAME``, but deletes a global name.
.. opcode:: LOAD_CONST (consti)
Pushes ``co_consts[consti]`` onto the stack.
.. opcode:: LOAD_NAME (namei)
Pushes the value associated with ``co_names[namei]`` onto the stack.
.. opcode:: BUILD_TUPLE (count)
Creates a tuple consuming *count* items from the stack, and pushes the resulting
tuple onto the stack.
.. opcode:: BUILD_LIST (count)
Works as ``BUILD_TUPLE``, but creates a list.
.. opcode:: BUILD_MAP (count)
2007-08-15 11:28:01 -03:00
Pushes a new dictionary object onto the stack. The dictionary is pre-sized
to hold *count* entries.
2007-08-15 11:28:01 -03:00
.. opcode:: LOAD_ATTR (namei)
Replaces TOS with ``getattr(TOS, co_names[namei])``.
.. opcode:: COMPARE_OP (opname)
Performs a Boolean operation. The operation name can be found in
``cmp_op[opname]``.
.. opcode:: IMPORT_NAME (namei)
2008-04-19 13:59:16 -03:00
Imports the module ``co_names[namei]``. TOS and TOS1 are popped and provide
the *fromlist* and *level* arguments of :func:`__import__`. The module
object is pushed onto the stack. The current namespace is not affected:
for a proper import statement, a subsequent ``STORE_FAST`` instruction
modifies the namespace.
2007-08-15 11:28:01 -03:00
.. opcode:: IMPORT_FROM (namei)
Loads the attribute ``co_names[namei]`` from the module found in TOS. The
resulting object is pushed onto the stack, to be subsequently stored by a
``STORE_FAST`` instruction.
.. opcode:: JUMP_FORWARD (delta)
Increments bytecode counter by *delta*.
2007-08-15 11:28:01 -03:00
.. opcode:: JUMP_IF_TRUE (delta)
If TOS is true, increment the bytecode counter by *delta*. TOS is left on the
2007-08-15 11:28:01 -03:00
stack.
.. opcode:: JUMP_IF_FALSE (delta)
If TOS is false, increment the bytecode counter by *delta*. TOS is not
2007-08-15 11:28:01 -03:00
changed.
.. opcode:: JUMP_ABSOLUTE (target)
Set bytecode counter to *target*.
2007-08-15 11:28:01 -03:00
.. opcode:: FOR_ITER (delta)
``TOS`` is an :term:`iterator`. Call its :meth:`!next` method. If this
2007-10-21 09:10:28 -03:00
yields a new value, push it on the stack (leaving the iterator below it). If
the iterator indicates it is exhausted ``TOS`` is popped, and the bytecode
counter is incremented by *delta*.
2007-08-15 11:28:01 -03:00
.. opcode:: LOAD_GLOBAL (namei)
Loads the global named ``co_names[namei]`` onto the stack.
.. opcode:: SETUP_LOOP (delta)
Pushes a block for a loop onto the block stack. The block spans from the
current instruction with a size of *delta* bytes.
.. opcode:: SETUP_EXCEPT (delta)
Pushes a try block from a try-except clause onto the block stack. *delta* points
to the first except block.
.. opcode:: SETUP_FINALLY (delta)
Pushes a try block from a try-except clause onto the block stack. *delta* points
to the finally block.
.. opcode:: STORE_MAP ()
Store a key and value pair in a dictionary. Pops the key and value while leaving
the dictionary on the stack.
2007-08-15 11:28:01 -03:00
.. opcode:: LOAD_FAST (var_num)
Pushes a reference to the local ``co_varnames[var_num]`` onto the stack.
.. opcode:: STORE_FAST (var_num)
Stores TOS into the local ``co_varnames[var_num]``.
.. opcode:: DELETE_FAST (var_num)
Deletes local ``co_varnames[var_num]``.
.. opcode:: LOAD_CLOSURE (i)
Pushes a reference to the cell contained in slot *i* of the cell and free
variable storage. The name of the variable is ``co_cellvars[i]`` if *i* is
less than the length of *co_cellvars*. Otherwise it is ``co_freevars[i -
len(co_cellvars)]``.
.. opcode:: LOAD_DEREF (i)
Loads the cell contained in slot *i* of the cell and free variable storage.
Pushes a reference to the object the cell contains on the stack.
.. opcode:: STORE_DEREF (i)
Stores TOS into the cell contained in slot *i* of the cell and free variable
storage.
.. opcode:: SET_LINENO (lineno)
This opcode is obsolete.
.. opcode:: RAISE_VARARGS (argc)
Raises an exception. *argc* indicates the number of parameters to the raise
statement, ranging from 0 to 3. The handler will find the traceback as TOS2,
the parameter as TOS1, and the exception as TOS.
.. opcode:: CALL_FUNCTION (argc)
Calls a function. The low byte of *argc* indicates the number of positional
parameters, the high byte the number of keyword parameters. On the stack, the
opcode finds the keyword parameters first. For each keyword argument, the value
is on top of the key. Below the keyword parameters, the positional parameters
are on the stack, with the right-most parameter on top. Below the parameters,
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r68133 | antoine.pitrou | 2009-01-01 16:38:03 +0100 (Thu, 01 Jan 2009) | 1 line fill in actual issue number in tests ........ r68134 | hirokazu.yamamoto | 2009-01-01 16:45:39 +0100 (Thu, 01 Jan 2009) | 2 lines Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open file with `str' filename on Windows. ........ r68141 | benjamin.peterson | 2009-01-01 17:43:12 +0100 (Thu, 01 Jan 2009) | 1 line fix highlighting ........ r68142 | benjamin.peterson | 2009-01-01 18:29:49 +0100 (Thu, 01 Jan 2009) | 2 lines welcome to 2009, Python! ........ r68145 | amaury.forgeotdarc | 2009-01-02 01:03:54 +0100 (Fri, 02 Jan 2009) | 5 lines #4801 _collections module fails to build on cygwin. _PyObject_GC_TRACK is the macro version of PyObject_GC_Track, and according to documentation it should not be used for extension modules. ........ r68146 | ronald.oussoren | 2009-01-02 11:44:46 +0100 (Fri, 02 Jan 2009) | 2 lines Fix for issue4472: "configure --enable-shared doesn't work on OSX" ........ r68148 | ronald.oussoren | 2009-01-02 11:48:31 +0100 (Fri, 02 Jan 2009) | 2 lines Forgot to add a NEWS item in my previous checkin ........ r68149 | ronald.oussoren | 2009-01-02 11:50:48 +0100 (Fri, 02 Jan 2009) | 2 lines Fix for issue4780 ........ r68159 | ronald.oussoren | 2009-01-02 15:48:17 +0100 (Fri, 02 Jan 2009) | 2 lines Fix for issue 1627952 ........ r68160 | ronald.oussoren | 2009-01-02 15:52:09 +0100 (Fri, 02 Jan 2009) | 2 lines Fix for issue r1737832 ........ r68161 | ronald.oussoren | 2009-01-02 16:00:05 +0100 (Fri, 02 Jan 2009) | 3 lines Fix for issue 1149804 ........ r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines Fix for issue 4472 is incompatible with Cygwin, this patch should fix that. ........ r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line document PyMemberDef ........ r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines #4811: fix markup glitches (mostly remains of the conversion), found by Gabriel Genellina. ........ r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fri, 02 Jan 2009) | 2 lines Issue #4075: Use OutputDebugStringW in Py_FatalError. ........ r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fri, 02 Jan 2009) | 2 lines Issue #4051: Prevent conflict of UNICODE macros in cPickle. ........ r68174 | benjamin.peterson | 2009-01-02 21:47:27 +0100 (Fri, 02 Jan 2009) | 1 line fix compilation on non-Windows platforms ........ r68179 | raymond.hettinger | 2009-01-02 22:26:45 +0100 (Fri, 02 Jan 2009) | 1 line Issue #4615. Document how to use itertools for de-duping. ........ r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines Remove useless string literal. ........ r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines Fix indentation. ........ r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines Set eol-style correctly for mp_distributing.py. ........ r68214 | georg.brandl | 2009-01-03 20:44:48 +0100 (Sat, 03 Jan 2009) | 2 lines Make indentation consistent. ........ r68215 | georg.brandl | 2009-01-03 21:15:14 +0100 (Sat, 03 Jan 2009) | 2 lines Fix role name. ........ r68217 | georg.brandl | 2009-01-03 21:30:15 +0100 (Sat, 03 Jan 2009) | 2 lines Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources. ........ r68218 | georg.brandl | 2009-01-03 21:38:59 +0100 (Sat, 03 Jan 2009) | 2 lines Recognize usage of the default role. ........ r68219 | georg.brandl | 2009-01-03 21:47:01 +0100 (Sat, 03 Jan 2009) | 2 lines Fix uses of the default role. ........ r68220 | georg.brandl | 2009-01-03 21:55:06 +0100 (Sat, 03 Jan 2009) | 2 lines Remove trailing whitespace. ........ r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines Remove tabs from the documentation. ........ r68222 | georg.brandl | 2009-01-03 22:11:58 +0100 (Sat, 03 Jan 2009) | 2 lines Disable the line length checker by default. ........
2009-01-03 17:55:17 -04:00
the function object to call is on the stack. Pops all function arguments, and
Merged revisions 66801,66803-66804,66813,66854-66856,66866,66870-66872,66874,66887,66903,66905,66911,66913,66927,66932,66938,66942,66962,66964,66973-66974,66977,66992,66998-66999,67002,67005,67007,67028,67040-67041,67044,67070,67089,67091,67101,67117-67119,67123-67124 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ................ r66801 | andrew.kuchling | 2008-10-04 23:51:59 +0200 (Sat, 04 Oct 2008) | 1 line Punctuation fix; expand dict.update docstring to be clearer ................ r66803 | benjamin.peterson | 2008-10-05 00:15:31 +0200 (Sun, 05 Oct 2008) | 1 line fix typo ................ r66804 | andrew.kuchling | 2008-10-05 02:11:56 +0200 (Sun, 05 Oct 2008) | 1 line #1415508 from Rocky Bernstein: add docstrings for enable_interspersed_args(), disable_interspersed_args() ................ r66813 | andrew.kuchling | 2008-10-06 14:07:04 +0200 (Mon, 06 Oct 2008) | 3 lines Per Greg Ward, optparse is no longer being externally maintained. I'll look at the bugs in the Optik bug tracker and copy them to the Python bug tracker if they're still relevant. ................ r66854 | georg.brandl | 2008-10-08 19:20:20 +0200 (Wed, 08 Oct 2008) | 2 lines #4059: patch up some sqlite docs. ................ r66855 | georg.brandl | 2008-10-08 19:30:55 +0200 (Wed, 08 Oct 2008) | 2 lines #4058: fix some whatsnew markup. ................ r66856 | georg.brandl | 2008-10-08 20:47:17 +0200 (Wed, 08 Oct 2008) | 3 lines #3935: properly support list subclasses in the C impl. of bisect. Patch reviewed by Raymond. ................ r66866 | benjamin.peterson | 2008-10-09 22:54:43 +0200 (Thu, 09 Oct 2008) | 1 line update paragraph about __future__ for 2.6 ................ r66870 | armin.rigo | 2008-10-10 10:40:44 +0200 (Fri, 10 Oct 2008) | 2 lines Typo: "ThreadError" is the name in the C source. ................ r66871 | benjamin.peterson | 2008-10-10 22:38:49 +0200 (Fri, 10 Oct 2008) | 1 line fix a small typo ................ r66872 | benjamin.peterson | 2008-10-10 22:51:37 +0200 (Fri, 10 Oct 2008) | 1 line talk about how you can unzip with zip ................ r66874 | benjamin.peterson | 2008-10-11 00:23:41 +0200 (Sat, 11 Oct 2008) | 1 line PyGILState_Acquire -> PyGILState_Ensure ................ r66887 | benjamin.peterson | 2008-10-13 23:51:40 +0200 (Mon, 13 Oct 2008) | 1 line document how to disable fixers ................ r66903 | benjamin.peterson | 2008-10-15 22:34:09 +0200 (Wed, 15 Oct 2008) | 1 line don't recurse into directories that start with '.' ................ r66905 | benjamin.peterson | 2008-10-15 23:05:55 +0200 (Wed, 15 Oct 2008) | 1 line support the optional line argument for idle ................ r66911 | benjamin.peterson | 2008-10-16 01:10:28 +0200 (Thu, 16 Oct 2008) | 41 lines Merged revisions 66805,66841,66860,66884-66886,66893,66907,66910 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r66805 | benjamin.peterson | 2008-10-04 20:11:02 -0500 (Sat, 04 Oct 2008) | 1 line mention what the fixes directory is for ........ r66841 | benjamin.peterson | 2008-10-07 17:48:12 -0500 (Tue, 07 Oct 2008) | 1 line use assertFalse and assertTrue ........ r66860 | benjamin.peterson | 2008-10-08 16:05:07 -0500 (Wed, 08 Oct 2008) | 1 line instead of abusing the pattern matcher, use start_tree to find a next binding ........ r66884 | benjamin.peterson | 2008-10-13 15:50:30 -0500 (Mon, 13 Oct 2008) | 1 line don't print tokens to stdout when -v is given ........ r66885 | benjamin.peterson | 2008-10-13 16:28:57 -0500 (Mon, 13 Oct 2008) | 1 line add the -x option to disable fixers ........ r66886 | benjamin.peterson | 2008-10-13 16:33:53 -0500 (Mon, 13 Oct 2008) | 1 line cut down on some crud ........ r66893 | benjamin.peterson | 2008-10-14 17:16:54 -0500 (Tue, 14 Oct 2008) | 1 line add an optional set literal fixer ........ r66907 | benjamin.peterson | 2008-10-15 16:59:41 -0500 (Wed, 15 Oct 2008) | 1 line don't write backup files by default ........ r66910 | benjamin.peterson | 2008-10-15 17:43:10 -0500 (Wed, 15 Oct 2008) | 1 line add the -n option; it stops backupfiles from being written ........ ................ r66913 | benjamin.peterson | 2008-10-16 20:52:14 +0200 (Thu, 16 Oct 2008) | 1 line document that deque indexing is O(n) #4123 ................ r66927 | andrew.kuchling | 2008-10-16 22:15:47 +0200 (Thu, 16 Oct 2008) | 1 line Fix wording (2.6.1 backport candidate) ................ r66932 | benjamin.peterson | 2008-10-16 23:09:28 +0200 (Thu, 16 Oct 2008) | 1 line check for error conditions in _json #3623 ................ r66938 | benjamin.peterson | 2008-10-16 23:27:54 +0200 (Thu, 16 Oct 2008) | 1 line fix possible ref leak ................ r66942 | benjamin.peterson | 2008-10-16 23:48:06 +0200 (Thu, 16 Oct 2008) | 1 line fix more possible ref leaks in _json and use Py_CLEAR ................ r66962 | benjamin.peterson | 2008-10-17 22:01:01 +0200 (Fri, 17 Oct 2008) | 1 line clarify CALL_FUNCTION #4141 ................ r66964 | georg.brandl | 2008-10-17 23:41:49 +0200 (Fri, 17 Oct 2008) | 2 lines Fix duplicate word. ................ r66973 | armin.ronacher | 2008-10-19 10:27:43 +0200 (Sun, 19 Oct 2008) | 3 lines Fixed #4067 by implementing _attributes and _fields for the AST root node. ................ r66974 | benjamin.peterson | 2008-10-19 15:59:01 +0200 (Sun, 19 Oct 2008) | 1 line fix compiler warning ................ r66977 | benjamin.peterson | 2008-10-19 21:39:16 +0200 (Sun, 19 Oct 2008) | 1 line mention -n ................ r66992 | benjamin.peterson | 2008-10-21 22:51:13 +0200 (Tue, 21 Oct 2008) | 1 line make sure to call iteritems() ................ r66998 | benjamin.peterson | 2008-10-22 22:57:43 +0200 (Wed, 22 Oct 2008) | 1 line fix a few typos ................ r66999 | benjamin.peterson | 2008-10-22 23:05:30 +0200 (Wed, 22 Oct 2008) | 1 line and another typo... ................ r67002 | hirokazu.yamamoto | 2008-10-23 02:37:33 +0200 (Thu, 23 Oct 2008) | 1 line Issue #4183: Some tests didn't run with pickle.HIGHEST_PROTOCOL. ................ r67005 | walter.doerwald | 2008-10-23 15:11:39 +0200 (Thu, 23 Oct 2008) | 2 lines Use the correct names of the stateless codec functions (Fixes issue 4178). ................ r67007 | benjamin.peterson | 2008-10-23 23:43:48 +0200 (Thu, 23 Oct 2008) | 1 line only nonempty __slots__ don't work ................ r67028 | benjamin.peterson | 2008-10-26 01:27:07 +0200 (Sun, 26 Oct 2008) | 1 line don't use a catch-all ................ r67040 | armin.rigo | 2008-10-28 18:01:21 +0100 (Tue, 28 Oct 2008) | 5 lines Fix one of the tests: it relied on being present in an "output test" in order to actually test what it was supposed to test, i.e. that the code in the __del__ method did not crash. Use instead the new helper test_support.captured_output(). ................ r67041 | benjamin.peterson | 2008-10-29 21:33:00 +0100 (Wed, 29 Oct 2008) | 1 line mention the version gettempdir() was added ................ r67044 | amaury.forgeotdarc | 2008-10-30 00:15:57 +0100 (Thu, 30 Oct 2008) | 3 lines Correct error message in io.open(): closefd=True is the only accepted value with a file name. ................ r67070 | benjamin.peterson | 2008-10-31 21:41:44 +0100 (Fri, 31 Oct 2008) | 1 line rephrase has_key doc ................ r67089 | benjamin.peterson | 2008-11-03 21:43:20 +0100 (Mon, 03 Nov 2008) | 1 line clarify by splitting into multiple paragraphs ................ r67091 | benjamin.peterson | 2008-11-03 23:34:57 +0100 (Mon, 03 Nov 2008) | 1 line move a FileIO test to test_fileio ................ r67101 | georg.brandl | 2008-11-04 21:49:35 +0100 (Tue, 04 Nov 2008) | 2 lines #4167: fix markup glitches. ................ r67117 | georg.brandl | 2008-11-06 11:17:58 +0100 (Thu, 06 Nov 2008) | 2 lines #4268: Use correct module for two toplevel functions. ................ r67118 | georg.brandl | 2008-11-06 11:19:11 +0100 (Thu, 06 Nov 2008) | 2 lines #4267: small fixes in sqlite3 docs. ................ r67119 | georg.brandl | 2008-11-06 11:20:49 +0100 (Thu, 06 Nov 2008) | 2 lines #4245: move Thread section to the top. ................ r67123 | georg.brandl | 2008-11-06 19:49:15 +0100 (Thu, 06 Nov 2008) | 2 lines #4247: add "pass" examples to tutorial. ................ r67124 | andrew.kuchling | 2008-11-06 20:23:02 +0100 (Thu, 06 Nov 2008) | 1 line Fix grammar error; reword two paragraphs ................
2008-11-07 04:56:27 -04:00
the function itself off the stack, and pushes the return value.
2007-08-15 11:28:01 -03:00
.. opcode:: MAKE_FUNCTION (argc)
Pushes a new function object on the stack. TOS is the code associated with the
function. The function object is defined to have *argc* default parameters,
which are found below TOS.
.. opcode:: MAKE_CLOSURE (argc)
Creates a new function object, sets its *func_closure* slot, and pushes it on
the stack. TOS is the code associated with the function, TOS1 the tuple
containing cells for the closure's free variables. The function also has
*argc* default parameters, which are found below the cells.
2007-08-15 11:28:01 -03:00
.. opcode:: BUILD_SLICE (argc)
.. index:: builtin: slice
Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2,
``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is
2007-12-29 06:57:00 -04:00
pushed. See the :func:`slice` built-in function for more information.
2007-08-15 11:28:01 -03:00
.. opcode:: EXTENDED_ARG (ext)
Prefixes any opcode which has an argument too big to fit into the default two
bytes. *ext* holds two additional bytes which, taken together with the
subsequent opcode's argument, comprise a four-byte argument, *ext* being the two
most-significant bytes.
.. opcode:: CALL_FUNCTION_VAR (argc)
Calls a function. *argc* is interpreted as in ``CALL_FUNCTION``. The top element
on the stack contains the variable argument list, followed by keyword and
positional arguments.
.. opcode:: CALL_FUNCTION_KW (argc)
Calls a function. *argc* is interpreted as in ``CALL_FUNCTION``. The top element
on the stack contains the keyword arguments dictionary, followed by explicit
keyword and positional arguments.
.. opcode:: CALL_FUNCTION_VAR_KW (argc)
Calls a function. *argc* is interpreted as in ``CALL_FUNCTION``. The top
element on the stack contains the keyword arguments dictionary, followed by the
variable-arguments tuple, followed by explicit keyword and positional arguments.
.. opcode:: HAVE_ARGUMENT ()
This is not really an opcode. It identifies the dividing line between opcodes
which don't take arguments ``< HAVE_ARGUMENT`` and those which do ``>=
HAVE_ARGUMENT``.