mirror of https://github.com/python/cpython.git
Get magic number from interpreter (using module imp).
This commit is contained in:
parent
aa3e163fa1
commit
2e5168c9fc
|
@ -2,7 +2,8 @@
|
||||||
# This has intimate knowledge of how Python/import.c does it.
|
# This has intimate knowledge of how Python/import.c does it.
|
||||||
# By Sjoerd Mullender (I forced him to write it :-).
|
# By Sjoerd Mullender (I forced him to write it :-).
|
||||||
|
|
||||||
MAGIC = 0x999903
|
import imp
|
||||||
|
MAGIC = imp.get_magic()
|
||||||
|
|
||||||
def wr_long(f, x):
|
def wr_long(f, x):
|
||||||
f.write(chr( x & 0xff))
|
f.write(chr( x & 0xff))
|
||||||
|
@ -20,7 +21,7 @@ def compile(file, cfile = None):
|
||||||
if not cfile:
|
if not cfile:
|
||||||
cfile = file + 'c'
|
cfile = file + 'c'
|
||||||
fc = open(cfile, 'wb')
|
fc = open(cfile, 'wb')
|
||||||
wr_long(fc, MAGIC)
|
fc.write(MAGIC)
|
||||||
wr_long(fc, timestamp)
|
wr_long(fc, timestamp)
|
||||||
marshal.dump(codeobject, fc)
|
marshal.dump(codeobject, fc)
|
||||||
fc.close()
|
fc.close()
|
||||||
|
|
Loading…
Reference in New Issue