diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/env.py | 27 | ||||
-rw-r--r-- | coverage/execfile.py | 6 | ||||
-rw-r--r-- | coverage/parser.py | 2 |
3 files changed, 29 insertions, 6 deletions
diff --git a/coverage/env.py b/coverage/env.py index 27602431..83b4be65 100644 --- a/coverage/env.py +++ b/coverage/env.py @@ -28,12 +28,39 @@ PY3 = PYVERSION >= (3, 0) class PYBEHAVIOR(object): """Flags indicating this Python's behavior.""" + # Is "if __debug__" optimized away? + optimize_if_debug = (not PYPY) + + # If "if not __debug__" optimized away? + optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4)) + + # Do we have yield-from? + yield_from = (PYVERSION >= (3, 3)) + + # Do we have PEP 420 namespace packages? + namespaces_pep420 = (PYVERSION >= (3, 3)) + # Do .pyc files have the source file size recorded in them? size_in_pyc = (PYVERSION >= (3, 3)) + # Do we have async and await syntax? + async_syntax = (PYVERSION >= (3, 5)) + + # PEP 448 defined additional unpacking generalizations + unpackings_pep448 = (PYVERSION >= (3, 5)) + + # Can co_lnotab have negative deltas? + negative_lnotab = (PYVERSION >= (3, 6)) + # 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 = (PYVERSION >= (3, 7, 0, 'beta', 3)) + # 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 0e78e5dc..97997b06 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -124,11 +124,7 @@ class PyRunner(object): should_update_sys_path = True if self.as_module: - # 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. - if env.PYVERSION >= (3, 7, 0, 'beta', 3): + if env.PYBEHAVIOR.actual_syspath0_dash_m: path0 = os.getcwd() else: path0 = "" diff --git a/coverage/parser.py b/coverage/parser.py index 1c19f69e..6ae99fe4 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -409,7 +409,7 @@ class ByteParser(object): yield (byte_num, line_num) last_line_num = line_num byte_num += byte_incr - if env.PYVERSION >= (3, 6) and line_incr >= 0x80: + if env.PYBEHAVIOR.negative_lnotab and line_incr >= 0x80: line_incr -= 0x100 line_num += line_incr if line_num != last_line_num: |