From a2c8f50b309d953b53ae59ee45f0cafec314559a Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Fri, 9 Feb 2018 16:43:25 -0500 Subject: [PATCH] Implement changes to support PEP 552 --- hy/_compat.py | 1 + hy/importer.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hy/_compat.py b/hy/_compat.py index dc5a7d6..a22bb13 100644 --- a/hy/_compat.py +++ b/hy/_compat.py @@ -23,6 +23,7 @@ import sys PY3 = sys.version_info[0] >= 3 PY35 = sys.version_info >= (3, 5) PY36 = sys.version_info >= (3, 6) +PY37 = sys.version_info >= (3, 7) str_type = str if PY3 else unicode # NOQA bytes_type = bytes if PY3 else str # NOQA diff --git a/hy/importer.py b/hy/importer.py index 58b484a..450de27 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -18,7 +18,7 @@ import inspect import os import __future__ -from hy._compat import PY3, MAGIC, builtins, long_type, wr_long +from hy._compat import PY3, PY37, MAGIC, builtins, long_type, wr_long from hy._compat import string_types @@ -220,6 +220,12 @@ def write_code_as_pyc(fname, code): with builtins.open(cfile, 'wb') as fc: fc.write(MAGIC) + if PY37: + # With PEP 552, the header structure has a new flags field + # that we need to fill in. All zeros preserve the legacy + # behaviour, but should we implement reproducible builds, + # this is where we'd add the information. + wr_long(fc, 0) wr_long(fc, timestamp) if PY3: wr_long(fc, st.st_size)