summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2010-08-17 10:18:16 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2010-08-17 10:18:16 (GMT)
commit09c8123e6f2d01444b03e7971f3e3dec37474490 (patch)
treeef40c7e94ccba25249313ecd46de2b131e99fd8a /Lib/dis.py
parent77203adb7e3c50775b768a846ebc03514e69be77 (diff)
downloadcpython-09c8123e6f2d01444b03e7971f3e3dec37474490.zip
cpython-09c8123e6f2d01444b03e7971f3e3dec37474490.tar.gz
cpython-09c8123e6f2d01444b03e7971f3e3dec37474490.tar.bz2
Address XXX comment in dis.py: inspect.py now attempts to reuse the dis.py compiler flag values before resorting to defining its own
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index b4159e0..a82d380 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -68,9 +68,10 @@ def distb(tb=None):
while tb.tb_next: tb = tb.tb_next
disassemble(tb.tb_frame.f_code, tb.tb_lasti)
-# XXX This duplicates information from code.h, also duplicated in inspect.py.
-# XXX Maybe this ought to be put in a central location, like opcode.py?
-flag2name = {
+# The inspect module interrogates this dictionary to build its
+# list of CO_* constants. It is also used by pretty_flags to
+# turn the co_flags field into a human readable list.
+COMPILER_FLAG_NAMES = {
1: "OPTIMIZED",
2: "NEWLOCALS",
4: "VARARGS",
@@ -86,7 +87,7 @@ def pretty_flags(flags):
for i in range(32):
flag = 1<<i
if flags & flag:
- names.append(flag2name.get(flag, hex(flag)))
+ names.append(COMPILER_FLAG_NAMES.get(flag, hex(flag)))
flags ^= flag
if not flags:
break