diff options
Diffstat (limited to 'Lib/dis.py')
| -rw-r--r-- | Lib/dis.py | 16 | 
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/dis.py b/Lib/dis.py index 841208ffa1..532a367bce 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -163,6 +163,15 @@ def show_code(co, *, file=None):  _Instruction = collections.namedtuple("_Instruction",       "opname opcode arg argval argrepr offset starts_line is_jump_target") +_Instruction.opname.__doc__ = "Human readable name for operation" +_Instruction.opcode.__doc__ = "Numeric code for operation" +_Instruction.arg.__doc__ = "Numeric argument to operation (if any), otherwise None" +_Instruction.argval.__doc__ = "Resolved arg value (if known), otherwise same as arg" +_Instruction.argrepr.__doc__ = "Human readable description of operation argument" +_Instruction.offset.__doc__ = "Start index of operation within bytecode sequence" +_Instruction.starts_line.__doc__ = "Line started by this opcode (if any), otherwise None" +_Instruction.is_jump_target.__doc__ = "True if other code jumps to here, otherwise False" +  class Instruction(_Instruction):      """Details for a bytecode operation @@ -389,8 +398,8 @@ def findlinestarts(code):      Generate pairs (offset, lineno) as described in Python/compile.c.      """ -    byte_increments = list(code.co_lnotab[0::2]) -    line_increments = list(code.co_lnotab[1::2]) +    byte_increments = code.co_lnotab[0::2] +    line_increments = code.co_lnotab[1::2]      lastlineno = None      lineno = code.co_firstlineno @@ -401,6 +410,9 @@ def findlinestarts(code):                  yield (addr, lineno)                  lastlineno = lineno              addr += byte_incr +        if line_incr >= 0x80: +            # line_increments is an array of 8-bit signed integers +            line_incr -= 0x100          lineno += line_incr      if lineno != lastlineno:          yield (addr, lineno)  | 
