eric7/DebugClients/Python/coverage/env.py

branch
eric7
changeset 8991
2fc945191992
parent 8929
fcca2fa618bf
equal deleted inserted replaced
8990:ca8e477c590c 8991:2fc945191992
37 if PYPY: 37 if PYPY:
38 optimize_if_debug = True 38 optimize_if_debug = True
39 else: 39 else:
40 optimize_if_debug = not pep626 40 optimize_if_debug = not pep626
41 41
42 # Is "if not __debug__" optimized away? 42 # Is "if not __debug__" optimized away? The exact details have changed
43 optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4)) 43 # across versions.
44 if pep626: 44 if pep626:
45 optimize_if_not_debug = False 45 optimize_if_not_debug = 1
46 if PYPY: 46 elif PYPY:
47 optimize_if_not_debug = True 47 if PYVERSION >= (3, 9):
48 48 optimize_if_not_debug = 2
49 # Is "if not __debug__" optimized away even better? 49 elif PYVERSION[:2] == (3, 8):
50 optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1)) 50 optimize_if_not_debug = 3
51 if pep626: 51 else:
52 optimize_if_not_debug2 = False 52 optimize_if_not_debug = 1
53 53 else:
54 # Yet another way to optimize "if not __debug__"? 54 if PYVERSION >= (3, 8, 0, 'beta', 1):
55 optimize_if_not_debug3 = (PYPY and PYVERSION >= (3, 8)) 55 optimize_if_not_debug = 2
56 else:
57 optimize_if_not_debug = 1
56 58
57 # Can co_lnotab have negative deltas? 59 # Can co_lnotab have negative deltas?
58 negative_lnotab = not (PYPY and PYPYVERSION < (7, 2)) 60 negative_lnotab = not (PYPY and PYPYVERSION < (7, 2))
59
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 61
72 # 3.7 changed how functions with only docstrings are numbered. 62 # 3.7 changed how functions with only docstrings are numbered.
73 docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10)) 63 docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10))
74 64
75 # When a break/continue/return statement in a try block jumps to a finally 65 # When a break/continue/return statement in a try block jumps to a finally
79 finally_jumps_back = ((3, 8) <= PYVERSION < (3, 10)) 69 finally_jumps_back = ((3, 8) <= PYVERSION < (3, 10))
80 70
81 # When a function is decorated, does the trace function get called for the 71 # When a function is decorated, does the trace function get called for the
82 # @-line and also the def-line (new behavior in 3.8)? Or just the @-line 72 # @-line and also the def-line (new behavior in 3.8)? Or just the @-line
83 # (old behavior)? 73 # (old behavior)?
84 trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8)) 74 trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8)) or (PYPY and PYVERSION >= (3, 9))
75
76 # Functions are no longer claimed to start at their earliest decorator even though
77 # the decorators are traced?
78 def_ast_no_decorator = (PYPY and PYVERSION >= (3, 9))
79
80 # CPython 3.11 now jumps to the decorator line again while executing
81 # the decorator.
82 trace_decorator_line_again = (CPYTHON and PYVERSION > (3, 11, 0, 'alpha', 3, 0))
85 83
86 # Are while-true loops optimized into absolute jumps with no loop setup? 84 # Are while-true loops optimized into absolute jumps with no loop setup?
87 nix_while_true = (PYVERSION >= (3, 8)) 85 nix_while_true = (PYVERSION >= (3, 8))
88 86
89 # Python 3.9a1 made sys.argv[0] and other reported files absolute paths. 87 # CPython 3.9a1 made sys.argv[0] and other reported files absolute paths.
90 report_absolute_files = (PYVERSION >= (3, 9)) 88 report_absolute_files = (CPYTHON and PYVERSION >= (3, 9))
91 89
92 # Lines after break/continue/return/raise are no longer compiled into the 90 # Lines after break/continue/return/raise are no longer compiled into the
93 # bytecode. They used to be marked as missing, now they aren't executable. 91 # bytecode. They used to be marked as missing, now they aren't executable.
94 omit_after_jump = pep626 92 omit_after_jump = pep626
95 93
127 TESTING = os.getenv('COVERAGE_TESTING', '') == 'True' 125 TESTING = os.getenv('COVERAGE_TESTING', '') == 'True'
128 126
129 # Environment COVERAGE_NO_CONTRACTS=1 can turn off contracts while debugging 127 # Environment COVERAGE_NO_CONTRACTS=1 can turn off contracts while debugging
130 # tests to remove noise from stack traces. 128 # tests to remove noise from stack traces.
131 # $set_env.py: COVERAGE_NO_CONTRACTS - Disable PyContracts to simplify stack traces. 129 # $set_env.py: COVERAGE_NO_CONTRACTS - Disable PyContracts to simplify stack traces.
132 USE_CONTRACTS = TESTING and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0))) 130 USE_CONTRACTS = (
131 TESTING
132 and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0)))
133 and (PYVERSION < (3, 11))
134 )
135
136 def debug_info():
137 """Return a list of (name, value) pairs for printing debug information."""
138 info = [
139 (name, value) for name, value in globals().items()
140 if not name.startswith("_") and
141 name not in {"PYBEHAVIOR", "debug_info"} and
142 not isinstance(value, type(os))
143 ]
144 info += [
145 (name, value) for name, value in PYBEHAVIOR.__dict__.items()
146 if not name.startswith("_")
147 ]
148 return sorted(info)

eric ide

mercurial