Kaydet (Commit) 775c3070 authored tarafından Georg Brandl's avatar Georg Brandl

#4222: document dis.findlabels() and dis.findlinestarts() and

put them into dis.__all__.
üst 2adde055
...@@ -64,10 +64,23 @@ The :mod:`dis` module defines the following functions and constants: ...@@ -64,10 +64,23 @@ The :mod:`dis` module defines the following functions and constants:
.. function:: disco(code[, lasti]) .. function:: disco(code[, lasti])
A synonym for disassemble. It is more convenient to type, and kept for A synonym for :func:`disassemble`. It is more convenient to type, and kept
compatibility with earlier Python releases. for compatibility with earlier Python releases.
.. function:: findlinestarts(code)
This generator function uses the ``co_firstlineno`` and ``co_lnotab``
attributes of the code object *code* to find the offsets which are starts of
lines in the source code. They are generated as ``(offset, lineno)`` pairs.
.. function:: findlabels(code)
Detect all offsets in the code object *code* which are jump targets, and
return a list of these offsets.
.. data:: opname .. data:: opname
Sequence of operation names, indexable using the bytecode. Sequence of operation names, indexable using the bytecode.
......
...@@ -6,7 +6,8 @@ import types ...@@ -6,7 +6,8 @@ import types
from opcode import * from opcode import *
from opcode import __all__ as _opcodes_all from opcode import __all__ as _opcodes_all
__all__ = ["dis","disassemble","distb","disco"] + _opcodes_all __all__ = ["dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels"] + _opcodes_all
del _opcodes_all del _opcodes_all
def dis(x=None): def dis(x=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment