Fix bytecode loading on Python 3.7

This commit is contained in:
Simon Gomizelj 2018-03-12 01:25:30 -04:00 committed by Kodi Arfer
parent 03eab21fbf
commit 97cb19a8a2

View File

@ -77,6 +77,9 @@ def import_file_to_module(module_name, fpath, loader=None):
# The first 4 bytes are the magic number for the version of Python
# that compiled this bytecode.
bytecode_magic = bc_f.read(4)
# Python 3.7 introduced a new flags entry in the header structure.
if PY37:
bc_f.read(4)
# The next 4 bytes, interpreted as a little-endian 32-bit integer,
# are the mtime of the corresponding source file.
bytecode_mtime, = struct.unpack('<i', bc_f.read(4))