summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1995-07-19 11:21:47 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1995-07-19 11:21:47 (GMT)
commit2e5168c9fce4b4ce876feb6999bad5e5fa411afb (patch)
treef368ad913759af76908c60bd83b68458c22b4534
parentaa3e163fa1edd89690b78c6db2bb209dabe1bc9a (diff)
downloadcpython-2e5168c9fce4b4ce876feb6999bad5e5fa411afb.zip
cpython-2e5168c9fce4b4ce876feb6999bad5e5fa411afb.tar.gz
cpython-2e5168c9fce4b4ce876feb6999bad5e5fa411afb.tar.bz2
Get magic number from interpreter (using module imp).
-rw-r--r--Lib/py_compile.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index e0375ea..3c2809b 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -2,7 +2,8 @@
# This has intimate knowledge of how Python/import.c does it.
# By Sjoerd Mullender (I forced him to write it :-).
-MAGIC = 0x999903
+import imp
+MAGIC = imp.get_magic()
def wr_long(f, x):
f.write(chr( x & 0xff))
@@ -20,7 +21,7 @@ def compile(file, cfile = None):
if not cfile:
cfile = file + 'c'
fc = open(cfile, 'wb')
- wr_long(fc, MAGIC)
+ fc.write(MAGIC)
wr_long(fc, timestamp)
marshal.dump(codeobject, fc)
fc.close()