Get magic number from interpreter (using module imp).

This commit is contained in:
Sjoerd Mullender 1995-07-19 11:21:47 +00:00
parent aa3e163fa1
commit 2e5168c9fc
1 changed files with 3 additions and 2 deletions

View File

@ -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()