PyDocs

Nav

Python Language Services

dis

pickletools

function (source)
  • dis(pickle, out=None, memo=None, indentlevel=4, annotate=0)
Produce a symbolic disassembly of a pickle.

'pickle' is a file-like object, or string, containing a (at least one)
pickle.  The pickle is disassembled from the current position, through
the first STOP opcode encountered.

Optional arg 'out' is a file-like object to which the disassembly is
printed.  It defaults to sys.stdout.

Optional arg 'memo' is a Python dict, used as the pickle's memo.  It
may be mutated by dis(), if the pickle contains PUT or BINPUT opcodes.
Passing the same memo object to another dis() call then allows disassembly
to proceed across multiple pickles that were all created by the same
pickler with the same memo.  Ordinarily you don't need to worry about this.

Optional arg 'indentlevel' is the number of blanks by which to indent
a new MARK level.  It defaults to 4.

Optional arg 'annotate' if nonzero instructs dis() to add short
description of the opcode on each line of disassembled output.
The value given to 'annotate' must be an integer and is used as a
hint for the column where annotation should start.  The default
value is 0, meaning no annotations.

In addition to printing the disassembly, some sanity checks are made:

+ All embedded opcode arguments "make sense".

+ Explicit and implicit pop operations have enough items on the stack.

+ When an opcode implicitly refers to a markobject, a markobject is
  actually on the stack.

+ A memo entry isn't referenced before it's defined.

+ The markobject isn't stored in the memo.
Changed in 3.2
  • 3.2: Added the annotate parameter.
0 Examples
No examples for pickletools/dis.
See Also
No see-alsos for pickletools/dis
0 Notes
No notes for dis