Skip to content

Commit 3d85264

Browse files
committed
refactor: remove code that was only needed for Python 3.6
1 parent 39f8f3e commit 3d85264

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

coverage/env.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,6 @@ class PYBEHAVIOR:
5757
# Can co_lnotab have negative deltas?
5858
negative_lnotab = not (PYPY and PYPYVERSION < (7, 2))
5959

60-
# Do .pyc files conform to PEP 552? Hash-based pyc's.
61-
hashed_pyc_pep552 = (PYVERSION >= (3, 7, 0, 'alpha', 4))
62-
63-
# Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It
64-
# used to be an empty string (meaning the current directory). It changed
65-
# to be the actual path to the current directory, so that os.chdir wouldn't
66-
# affect the outcome.
67-
actual_syspath0_dash_m = (
68-
(CPYTHON and (PYVERSION >= (3, 7, 0, 'beta', 3))) or
69-
(PYPY and (PYPYVERSION >= (7, 3, 4)))
70-
)
71-
7260
# 3.7 changed how functions with only docstrings are numbered.
7361
docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10))
7462

coverage/execfile.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ def prepare(self):
8080
This needs to happen before any importing, and without importing anything.
8181
"""
8282
if self.as_module:
83-
if env.PYBEHAVIOR.actual_syspath0_dash_m:
84-
path0 = os.getcwd()
85-
else:
86-
path0 = ""
83+
path0 = os.getcwd()
8784
elif os.path.isdir(self.arg0):
8885
# Running a directory means running the __main__.py file in that
8986
# directory.
@@ -295,18 +292,14 @@ def make_code_from_pyc(filename):
295292
if magic != PYC_MAGIC_NUMBER:
296293
raise NoCode(f"Bad magic number in .pyc file: {magic!r} != {PYC_MAGIC_NUMBER!r}")
297294

298-
date_based = True
299-
if env.PYBEHAVIOR.hashed_pyc_pep552:
300-
flags = struct.unpack('<L', fpyc.read(4))[0]
301-
hash_based = flags & 0x01
302-
if hash_based:
303-
fpyc.read(8) # Skip the hash.
304-
date_based = False
305-
if date_based:
295+
flags = struct.unpack('<L', fpyc.read(4))[0]
296+
hash_based = flags & 0x01
297+
if hash_based:
298+
fpyc.read(8) # Skip the hash.
299+
else:
306300
# Skip the junk in the header that we don't need.
307-
fpyc.read(4) # Skip the moddate.
308-
# 3.3 added another long to the header (size), skip it.
309-
fpyc.read(4)
301+
fpyc.read(4) # Skip the moddate.
302+
fpyc.read(4) # Skip the size.
310303

311304
# The rest of the file is the code object we want.
312305
code = marshal.load(fpyc)

tests/test_execfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ def test_running_pyc_from_wrong_python(self):
242242
# In some environments, the pycfile persists and pollutes another test.
243243
os.remove(pycfile)
244244

245-
@pytest.mark.skipif(not env.PYBEHAVIOR.hashed_pyc_pep552, reason="No hashed .pyc here")
246245
def test_running_hashed_pyc(self):
247246
pycfile = self.make_pyc(invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH)
248247
run_python_file([pycfile])

0 commit comments

Comments
 (0)