From 3d8526412e90f645ecc4b3ae9b567cb2c73fe3aa Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 31 Dec 2021 12:57:11 -0500 Subject: refactor: remove code that was only needed for Python 3.6 --- coverage/env.py | 12 ------------ coverage/execfile.py | 23 ++++++++--------------- tests/test_execfile.py | 1 - 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/coverage/env.py b/coverage/env.py index f20b083e..a00cfa07 100644 --- a/coverage/env.py +++ b/coverage/env.py @@ -57,18 +57,6 @@ class PYBEHAVIOR: # Can co_lnotab have negative deltas? negative_lnotab = not (PYPY and PYPYVERSION < (7, 2)) - # Do .pyc files conform to PEP 552? Hash-based pyc's. - hashed_pyc_pep552 = (PYVERSION >= (3, 7, 0, 'alpha', 4)) - - # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It - # used to be an empty string (meaning the current directory). It changed - # to be the actual path to the current directory, so that os.chdir wouldn't - # affect the outcome. - actual_syspath0_dash_m = ( - (CPYTHON and (PYVERSION >= (3, 7, 0, 'beta', 3))) or - (PYPY and (PYPYVERSION >= (7, 3, 4))) - ) - # 3.7 changed how functions with only docstrings are numbered. docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10)) diff --git a/coverage/execfile.py b/coverage/execfile.py index 01ddd0cd..b5d3a65f 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -80,10 +80,7 @@ class PyRunner: This needs to happen before any importing, and without importing anything. """ if self.as_module: - if env.PYBEHAVIOR.actual_syspath0_dash_m: - path0 = os.getcwd() - else: - path0 = "" + path0 = os.getcwd() elif os.path.isdir(self.arg0): # Running a directory means running the __main__.py file in that # directory. @@ -295,18 +292,14 @@ def make_code_from_pyc(filename): if magic != PYC_MAGIC_NUMBER: raise NoCode(f"Bad magic number in .pyc file: {magic!r} != {PYC_MAGIC_NUMBER!r}") - date_based = True - if env.PYBEHAVIOR.hashed_pyc_pep552: - flags = struct.unpack('