summaryrefslogtreecommitdiffstats
path: root/Tools/compiler
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:08:20 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:08:20 (GMT)
commitce0c19c4a84f0486fd1b52da735d9ec1e27e9016 (patch)
tree823c09b864756ed95f7c34fa8a05ecf5c4d16c25 /Tools/compiler
parent37c9351cf6efbe58e01fd879a1d60cc6073ced6b (diff)
downloadcpython-ce0c19c4a84f0486fd1b52da735d9ec1e27e9016.zip
cpython-ce0c19c4a84f0486fd1b52da735d9ec1e27e9016.tar.gz
cpython-ce0c19c4a84f0486fd1b52da735d9ec1e27e9016.tar.bz2
Only print attributes that start with co_.
If passed a .py file as an argument, try to find its accompanying .pyc.
Diffstat (limited to 'Tools/compiler')
-rwxr-xr-xTools/compiler/dumppyc.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Tools/compiler/dumppyc.py b/Tools/compiler/dumppyc.py
index 4ab9821..dd460c9 100755
--- a/Tools/compiler/dumppyc.py
+++ b/Tools/compiler/dumppyc.py
@@ -1,13 +1,16 @@
#! /usr/bin/env python
import marshal
+import os
import dis
import types
def dump(obj):
print obj
for attr in dir(obj):
- print "\t", attr, repr(getattr(obj, attr))
+ if attr.startswith('co_'):
+ val = getattr(obj, attr)
+ print "\t", attr, repr(val)
def loadCode(path):
f = open(path)
@@ -36,4 +39,6 @@ if __name__ == "__main__":
else:
filename = sys.argv[1]
codename = None
+ if filename.endswith('.py') and os.path.exists(filename+"c"):
+ filename += "c"
main(filename, codename)