summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-11-18 15:47:55 (GMT)
committerGuido van Rossum <guido@python.org>1997-11-18 15:47:55 (GMT)
commit421c2240445f4f3b9a6233064bc16f42633101f7 (patch)
tree366998bdb60d0bee0f1f78928df2d5479c66ecc5
parente4a93bc4b3a371f52bcdbc82e03289fe722cdbdd (diff)
downloadcpython-421c2240445f4f3b9a6233064bc16f42633101f7.zip
cpython-421c2240445f4f3b9a6233064bc16f42633101f7.tar.gz
cpython-421c2240445f4f3b9a6233064bc16f42633101f7.tar.bz2
Added docstrings (contributed by Martin von Loewis).
-rw-r--r--Lib/dis.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index edae3b6..a012c17 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -1,10 +1,15 @@
-# Disassembler
+"""Disassembler of Python byte code into mnemonics."""
import sys
import string
import types
def dis(x=None):
+ """Disassemble classes, methods, functions, or code.
+
+ With no argument, disassemble the last traceback.
+
+ """
if not x:
distb()
return
@@ -36,6 +41,7 @@ def dis(x=None):
type(x).__name__
def distb(tb=None):
+ """Disassemble a traceback (default: last traceback)."""
if not tb:
try:
tb = sys.last_traceback
@@ -45,6 +51,7 @@ def distb(tb=None):
disassemble(tb.tb_frame.f_code, tb.tb_lasti)
def disassemble(co, lasti=-1):
+ """Disassemble a code object."""
code = co.co_code
labels = findlabels(code)
n = len(code)
@@ -79,6 +86,11 @@ def disassemble(co, lasti=-1):
disco = disassemble
def findlabels(code):
+ """Detect all offsets in a byte code which are jump targets.
+
+ Return the list of offsets.
+
+ """
labels = []
n = len(code)
i = 0