summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-08 09:34:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-08 09:34:25 (GMT)
commitdd102f7af8bc319205e7efd726af48d50a5ac103 (patch)
treed5feac621292f0f9e773b9e91b264dcde5e16e88 /Lib/dis.py
parent56588b7055a3c503bb7226a41d10be47f4bf2d58 (diff)
downloadcpython-dd102f7af8bc319205e7efd726af48d50a5ac103.zip
cpython-dd102f7af8bc319205e7efd726af48d50a5ac103.tar.gz
cpython-dd102f7af8bc319205e7efd726af48d50a5ac103.tar.bz2
Issue #28317: The disassembler now decodes FORMAT_VALUE argument.
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 3a706be..0794b7f 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -16,6 +16,8 @@ del _opcodes_all
_have_code = (types.MethodType, types.FunctionType, types.CodeType,
classmethod, staticmethod, type)
+FORMAT_VALUE = opmap['FORMAT_VALUE']
+
def _try_compile(source, name):
"""Attempts to compile the given source, first as an expression and
then as a statement if the first approach fails.
@@ -314,6 +316,13 @@ def _get_instructions_bytes(code, varnames=None, names=None, constants=None,
argrepr = argval
elif op in hasfree:
argval, argrepr = _get_name_info(arg, cells)
+ elif op == FORMAT_VALUE:
+ argval = ((None, str, repr, ascii)[arg & 0x3], bool(arg & 0x4))
+ argrepr = ('', 'str', 'repr', 'ascii')[arg & 0x3]
+ if argval[1]:
+ if argrepr:
+ argrepr += ', '
+ argrepr += 'with format'
yield Instruction(opname[op], op,
arg, argval, argrepr,
offset, starts_line, is_jump_target)