eric7/DebugClients/Python/coverage/env.py

branch
eric7
changeset 8775
0802ae193343
parent 8527
2bd1325d727e
child 8929
fcca2fa618bf
--- a/eric7/DebugClients/Python/coverage/env.py	Fri Nov 19 19:28:47 2021 +0100
+++ b/eric7/DebugClients/Python/coverage/env.py	Sat Nov 20 16:47:38 2021 +0100
@@ -20,26 +20,21 @@
 # Python versions. We amend version_info with one more value, a zero if an
 # official version, or 1 if built from source beyond an official version.
 PYVERSION = sys.version_info + (int(platform.python_version()[-1] == "+"),)
-PY2 = PYVERSION < (3, 0)
-PY3 = PYVERSION >= (3, 0)
 
 if PYPY:
     PYPYVERSION = sys.pypy_version_info
 
-PYPY2 = PYPY and PY2
-PYPY3 = PYPY and PY3
-
 # Python behavior.
-class PYBEHAVIOR(object):
+class PYBEHAVIOR:
     """Flags indicating this Python's behavior."""
 
+    # Does Python conform to PEP626, Precise line numbers for debugging and other tools.
+    # https://www.python.org/dev/peps/pep-0626
     pep626 = CPYTHON and (PYVERSION > (3, 10, 0, 'alpha', 4))
 
     # Is "if __debug__" optimized away?
-    if PYPY3:
+    if PYPY:
         optimize_if_debug = True
-    elif PYPY2:
-        optimize_if_debug = False
     else:
         optimize_if_debug = not pep626
 
@@ -47,7 +42,7 @@
     optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4))
     if pep626:
         optimize_if_not_debug = False
-    if PYPY3:
+    if PYPY:
         optimize_if_not_debug = True
 
     # Is "if not __debug__" optimized away even better?
@@ -55,23 +50,11 @@
     if pep626:
         optimize_if_not_debug2 = False
 
-    # 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))
+    # Yet another way to optimize "if not __debug__"?
+    optimize_if_not_debug3 = (PYPY and PYVERSION >= (3, 8))
 
     # Can co_lnotab have negative deltas?
-    negative_lnotab = (PYVERSION >= (3, 6)) and not (PYPY and PYPYVERSION < (7, 2))
+    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))
@@ -80,7 +63,10 @@
     # 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))
+    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))
@@ -94,7 +80,7 @@
     # When a function is decorated, does the trace function get called for the
     # @-line and also the def-line (new behavior in 3.8)? Or just the @-line
     # (old behavior)?
-    trace_decorated_def = (PYVERSION >= (3, 8))
+    trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8))
 
     # Are while-true loops optimized into absolute jumps with no loop setup?
     nix_while_true = (PYVERSION >= (3, 8))
@@ -116,6 +102,16 @@
     # Are "if 0:" lines (and similar) kept in the compiled code?
     keep_constant_test = pep626
 
+    # When leaving a with-block, do we visit the with-line again for the exit?
+    exit_through_with = (PYVERSION >= (3, 10, 0, 'beta'))
+
+    # Match-case construct.
+    match_case = (PYVERSION >= (3, 10))
+
+    # Some words are keywords in some places, identifiers in other places.
+    soft_keywords = (PYVERSION >= (3, 10))
+
+
 # Coverage.py specifics.
 
 # Are we using the C-implemented trace function?
@@ -128,3 +124,8 @@
 # Even when running tests, you can use COVERAGE_TESTING=0 to disable the
 # test-specific behavior like contracts.
 TESTING = os.getenv('COVERAGE_TESTING', '') == 'True'
+
+# Environment COVERAGE_NO_CONTRACTS=1 can turn off contracts while debugging
+# tests to remove noise from stack traces.
+# $set_env.py: COVERAGE_NO_CONTRACTS - Disable PyContracts to simplify stack traces.
+USE_CONTRACTS = TESTING and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0)))

eric ide

mercurial