eric7/DebugClients/Python/coverage/env.py

branch
eric7
changeset 8991
2fc945191992
parent 8929
fcca2fa618bf
--- a/eric7/DebugClients/Python/coverage/env.py	Sun Mar 20 17:26:35 2022 +0100
+++ b/eric7/DebugClients/Python/coverage/env.py	Sun Mar 20 17:49:44 2022 +0100
@@ -39,36 +39,26 @@
     else:
         optimize_if_debug = not pep626
 
-    # Is "if not __debug__" optimized away?
-    optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4))
+    # Is "if not __debug__" optimized away? The exact details have changed
+    # across versions.
     if pep626:
-        optimize_if_not_debug = False
-    if PYPY:
-        optimize_if_not_debug = True
-
-    # Is "if not __debug__" optimized away even better?
-    optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1))
-    if pep626:
-        optimize_if_not_debug2 = False
-
-    # Yet another way to optimize "if not __debug__"?
-    optimize_if_not_debug3 = (PYPY and PYVERSION >= (3, 8))
+        optimize_if_not_debug = 1
+    elif PYPY:
+        if PYVERSION >= (3, 9):
+            optimize_if_not_debug = 2
+        elif PYVERSION[:2] == (3, 8):
+            optimize_if_not_debug = 3
+        else:
+            optimize_if_not_debug = 1
+    else:
+        if PYVERSION >= (3, 8, 0, 'beta', 1):
+            optimize_if_not_debug = 2
+        else:
+            optimize_if_not_debug = 1
 
     # 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))
 
@@ -81,13 +71,21 @@
     # 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 = (CPYTHON and PYVERSION >= (3, 8))
+    trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8)) or (PYPY and PYVERSION >= (3, 9))
+
+    # Functions are no longer claimed to start at their earliest decorator even though
+    # the decorators are traced?
+    def_ast_no_decorator = (PYPY and PYVERSION >= (3, 9))
+
+    # CPython 3.11 now jumps to the decorator line again while executing
+    # the decorator.
+    trace_decorator_line_again = (CPYTHON and PYVERSION > (3, 11, 0, 'alpha', 3, 0))
 
     # Are while-true loops optimized into absolute jumps with no loop setup?
     nix_while_true = (PYVERSION >= (3, 8))
 
-    # Python 3.9a1 made sys.argv[0] and other reported files absolute paths.
-    report_absolute_files = (PYVERSION >= (3, 9))
+    # CPython 3.9a1 made sys.argv[0] and other reported files absolute paths.
+    report_absolute_files = (CPYTHON and PYVERSION >= (3, 9))
 
     # Lines after break/continue/return/raise are no longer compiled into the
     # bytecode.  They used to be marked as missing, now they aren't executable.
@@ -129,4 +127,22 @@
 # 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)))
+USE_CONTRACTS = (
+    TESTING
+    and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0)))
+    and (PYVERSION < (3, 11))
+)
+
+def debug_info():
+    """Return a list of (name, value) pairs for printing debug information."""
+    info = [
+        (name, value) for name, value in globals().items()
+        if not name.startswith("_") and
+            name not in {"PYBEHAVIOR", "debug_info"} and
+            not isinstance(value, type(os))
+    ]
+    info += [
+        (name, value) for name, value in PYBEHAVIOR.__dict__.items()
+        if not name.startswith("_")
+    ]
+    return sorted(info)

eric ide

mercurial