fix compiled app in py3

This commit is contained in:
ilvalle
2016-06-25 13:27:35 +02:00
parent 8aecaf4514
commit abf8d9fb27
3 changed files with 16 additions and 18 deletions
+6 -8
View File
@@ -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):