summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-01 12:09:40 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-01 12:09:40 (GMT)
commit775c30706882291fe6385066899f702f768ed95f (patch)
treee64dacc8ba3e477eb74ed44e26761c94226bddb2
parent2adde0551a51002c9a43bfabf684be0c960ed192 (diff)
downloadcpython-775c30706882291fe6385066899f702f768ed95f.zip
cpython-775c30706882291fe6385066899f702f768ed95f.tar.gz
cpython-775c30706882291fe6385066899f702f768ed95f.tar.bz2
#4222: document dis.findlabels() and dis.findlinestarts() and
put them into dis.__all__.
-rw-r--r--Doc/library/dis.rst17
-rw-r--r--Lib/dis.py3
2 files changed, 17 insertions, 3 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index e9cbb13..909e229 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -64,10 +64,23 @@ The :mod:`dis` module defines the following functions and constants:
.. function:: disco(code[, lasti])
- A synonym for disassemble. It is more convenient to type, and kept for
- compatibility with earlier Python releases.
+ A synonym for :func:`disassemble`. It is more convenient to type, and kept
+ 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
Sequence of operation names, indexable using the bytecode.
diff --git a/Lib/dis.py b/Lib/dis.py
index 5a74b3a..e60e702 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -6,7 +6,8 @@ import types
from opcode import *
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
def dis(x=None):