]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
If there is no .pyc file, just compile the code directly.
authorJeremy Hylton <jeremy@alum.mit.edu>
Wed, 11 Feb 2004 19:10:40 +0000 (19:10 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Wed, 11 Feb 2004 19:10:40 +0000 (19:10 +0000)
Tools/compiler/dumppyc.py

index dd460c9911856d9a765ca8049d5b83d02aee15d8..5ff67baaaaaf212e0c22f537695fd6b8d7c68332 100755 (executable)
@@ -13,11 +13,14 @@ def dump(obj):
             print "\t", attr, repr(val)
 
 def loadCode(path):
-    f = open(path)
-    f.read(8)
-    co = marshal.load(f)
-    f.close()
-    return co
+    if path[-1] == "c":
+        f = open(path)
+        f.read(8)
+        co = marshal.load(f)
+        f.close()
+        return co
+    else:
+        return compile(open(path).read(), path, "exec")
 
 def walk(co, match=None):
     if match is None or co.co_name == match: