eric7/DebugClients/Python/coverage/env.py

branch
eric7
changeset 8527
2bd1325d727e
parent 8312
800c432b34c8
child 8775
0802ae193343
equal deleted inserted replaced
8526:587202572b10 8527:2bd1325d727e
9 9
10 # Operating systems. 10 # Operating systems.
11 WINDOWS = sys.platform == "win32" 11 WINDOWS = sys.platform == "win32"
12 LINUX = sys.platform.startswith("linux") 12 LINUX = sys.platform.startswith("linux")
13 13
14 # Python implementations.
15 CPYTHON = (platform.python_implementation() == "CPython")
16 PYPY = (platform.python_implementation() == "PyPy")
17 JYTHON = (platform.python_implementation() == "Jython")
18 IRONPYTHON = (platform.python_implementation() == "IronPython")
19
14 # Python versions. We amend version_info with one more value, a zero if an 20 # Python versions. We amend version_info with one more value, a zero if an
15 # official version, or 1 if built from source beyond an official version. 21 # official version, or 1 if built from source beyond an official version.
16 PYVERSION = sys.version_info + (int(platform.python_version()[-1] == "+"),) 22 PYVERSION = sys.version_info + (int(platform.python_version()[-1] == "+"),)
17 PY2 = PYVERSION < (3, 0) 23 PY2 = PYVERSION < (3, 0)
18 PY3 = PYVERSION >= (3, 0) 24 PY3 = PYVERSION >= (3, 0)
19 25
20 # Python implementations.
21 PYPY = (platform.python_implementation() == 'PyPy')
22 if PYPY: 26 if PYPY:
23 PYPYVERSION = sys.pypy_version_info 27 PYPYVERSION = sys.pypy_version_info
24 28
25 PYPY2 = PYPY and PY2 29 PYPY2 = PYPY and PY2
26 PYPY3 = PYPY and PY3 30 PYPY3 = PYPY and PY3
27 31
28 JYTHON = (platform.python_implementation() == 'Jython') 32 # Python behavior.
29 IRONPYTHON = (platform.python_implementation() == 'IronPython')
30
31 # Python behavior
32 class PYBEHAVIOR(object): 33 class PYBEHAVIOR(object):
33 """Flags indicating this Python's behavior.""" 34 """Flags indicating this Python's behavior."""
34 35
36 pep626 = CPYTHON and (PYVERSION > (3, 10, 0, 'alpha', 4))
37
35 # Is "if __debug__" optimized away? 38 # Is "if __debug__" optimized away?
36 optimize_if_debug = (not PYPY) 39 if PYPY3:
40 optimize_if_debug = True
41 elif PYPY2:
42 optimize_if_debug = False
43 else:
44 optimize_if_debug = not pep626
37 45
38 # Is "if not __debug__" optimized away? 46 # Is "if not __debug__" optimized away?
39 optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4)) 47 optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4))
48 if pep626:
49 optimize_if_not_debug = False
50 if PYPY3:
51 optimize_if_not_debug = True
40 52
41 # Is "if not __debug__" optimized away even better? 53 # Is "if not __debug__" optimized away even better?
42 optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1)) 54 optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1))
55 if pep626:
56 optimize_if_not_debug2 = False
43 57
44 # Do we have yield-from? 58 # Do we have yield-from?
45 yield_from = (PYVERSION >= (3, 3)) 59 yield_from = (PYVERSION >= (3, 3))
46 60
47 # Do we have PEP 420 namespace packages? 61 # Do we have PEP 420 namespace packages?
64 78
65 # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It 79 # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It
66 # used to be an empty string (meaning the current directory). It changed 80 # used to be an empty string (meaning the current directory). It changed
67 # to be the actual path to the current directory, so that os.chdir wouldn't 81 # to be the actual path to the current directory, so that os.chdir wouldn't
68 # affect the outcome. 82 # affect the outcome.
69 actual_syspath0_dash_m = (not PYPY) and (PYVERSION >= (3, 7, 0, 'beta', 3)) 83 actual_syspath0_dash_m = CPYTHON and (PYVERSION >= (3, 7, 0, 'beta', 3))
84
85 # 3.7 changed how functions with only docstrings are numbered.
86 docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10))
70 87
71 # When a break/continue/return statement in a try block jumps to a finally 88 # When a break/continue/return statement in a try block jumps to a finally
72 # block, does the finally block do the break/continue/return (pre-3.8), or 89 # block, does the finally block do the break/continue/return (pre-3.8), or
73 # does the finally jump back to the break/continue/return (3.8) to do the 90 # does the finally jump back to the break/continue/return (3.8) to do the
74 # work? 91 # work?
75 finally_jumps_back = (PYVERSION >= (3, 8)) 92 finally_jumps_back = ((3, 8) <= PYVERSION < (3, 10))
76 93
77 # When a function is decorated, does the trace function get called for the 94 # When a function is decorated, does the trace function get called for the
78 # @-line and also the def-line (new behavior in 3.8)? Or just the @-line 95 # @-line and also the def-line (new behavior in 3.8)? Or just the @-line
79 # (old behavior)? 96 # (old behavior)?
80 trace_decorated_def = (PYVERSION >= (3, 8)) 97 trace_decorated_def = (PYVERSION >= (3, 8))
82 # Are while-true loops optimized into absolute jumps with no loop setup? 99 # Are while-true loops optimized into absolute jumps with no loop setup?
83 nix_while_true = (PYVERSION >= (3, 8)) 100 nix_while_true = (PYVERSION >= (3, 8))
84 101
85 # Python 3.9a1 made sys.argv[0] and other reported files absolute paths. 102 # Python 3.9a1 made sys.argv[0] and other reported files absolute paths.
86 report_absolute_files = (PYVERSION >= (3, 9)) 103 report_absolute_files = (PYVERSION >= (3, 9))
104
105 # Lines after break/continue/return/raise are no longer compiled into the
106 # bytecode. They used to be marked as missing, now they aren't executable.
107 omit_after_jump = pep626
108
109 # PyPy has always omitted statements after return.
110 omit_after_return = omit_after_jump or PYPY
111
112 # Modules used to have firstlineno equal to the line number of the first
113 # real line of code. Now they always start at 1.
114 module_firstline_1 = pep626
115
116 # Are "if 0:" lines (and similar) kept in the compiled code?
117 keep_constant_test = pep626
87 118
88 # Coverage.py specifics. 119 # Coverage.py specifics.
89 120
90 # Are we using the C-implemented trace function? 121 # Are we using the C-implemented trace function?
91 C_TRACER = os.getenv('COVERAGE_TEST_TRACER', 'c') == 'c' 122 C_TRACER = os.getenv('COVERAGE_TEST_TRACER', 'c') == 'c'

eric ide

mercurial