fix compiled app in py3
This commit is contained in:
+6
-8
@@ -44,18 +44,15 @@ from functools import reduce
|
||||
logger = logging.getLogger("web2py")
|
||||
from gluon import rewrite
|
||||
from gluon.custom_import import custom_import_install
|
||||
|
||||
try:
|
||||
import py_compile
|
||||
except:
|
||||
logger.warning('unable to import py_compile')
|
||||
import py_compile
|
||||
|
||||
is_pypy = settings.global_settings.is_pypy
|
||||
is_gae = settings.global_settings.web2py_runtime_gae
|
||||
is_jython = settings.global_settings.is_jython
|
||||
|
||||
pjoin = os.path.join
|
||||
|
||||
marshal_header_size = 8 if PY2 else 12
|
||||
|
||||
TEST_CODE = \
|
||||
r"""
|
||||
def _TEST():
|
||||
@@ -456,7 +453,8 @@ def save_pyc(filename):
|
||||
"""
|
||||
Bytecode compiles the file `filename`
|
||||
"""
|
||||
py_compile.compile(filename)
|
||||
cfile = "%sc" % filename
|
||||
py_compile.compile(filename, cfile=cfile)
|
||||
|
||||
|
||||
def read_pyc(filename):
|
||||
@@ -470,7 +468,7 @@ def read_pyc(filename):
|
||||
data = read_file(filename, 'rb')
|
||||
if not is_gae and data[:4] != imp.get_magic():
|
||||
raise SystemError('compiled code is incompatible')
|
||||
return marshal.loads(data[8:])
|
||||
return marshal.loads(data[marshal_header_size:])
|
||||
|
||||
|
||||
def compile_views(folder, skip_failed_views=False):
|
||||
|
||||
Reference in New Issue
Block a user