summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/env.py6
-rw-r--r--coverage/execfile.py4
2 files changed, 8 insertions, 2 deletions
diff --git a/coverage/env.py b/coverage/env.py
index d97b193c..27602431 100644
--- a/coverage/env.py
+++ b/coverage/env.py
@@ -28,6 +28,12 @@ PY3 = PYVERSION >= (3, 0)
class PYBEHAVIOR(object):
"""Flags indicating this Python's behavior."""
+ # Do .pyc files have the source file size recorded in them?
+ size_in_pyc = (PYVERSION >= (3, 3))
+
+ # Do .pyc files conform to PEP 552? Hash-based pyc's.
+ hashed_pyc_pep552 = (PYVERSION >= (3, 7, 0, 'alpha', 4))
+
# When a break/continue/return statement in a try block jumps to a finally
# block, does the finally block do the break/continue/return (pre-3.8), or
# does the finally jump back to the break/continue/return (3.8) to do the
diff --git a/coverage/execfile.py b/coverage/execfile.py
index 4fc6a85f..0e78e5dc 100644
--- a/coverage/execfile.py
+++ b/coverage/execfile.py
@@ -290,7 +290,7 @@ def make_code_from_pyc(filename):
raise NoCode("Bad magic number in .pyc file")
date_based = True
- if env.PYVERSION >= (3, 7, 0, 'alpha', 4):
+ if env.PYBEHAVIOR.hashed_pyc_pep552:
flags = struct.unpack('<L', fpyc.read(4))[0]
hash_based = flags & 0x01
if hash_based:
@@ -299,7 +299,7 @@ def make_code_from_pyc(filename):
if date_based:
# Skip the junk in the header that we don't need.
fpyc.read(4) # Skip the moddate.
- if env.PYVERSION >= (3, 3):
+ if env.PYBEHAVIOR.size_in_pyc:
# 3.3 added another long to the header (size), skip it.
fpyc.read(4)