Skip to content

Commit 22cd381

Browse files
authored
Merge branch 'master' into master
2 parents 01779db + 2afe04d commit 22cd381

19 files changed

+548
-976
lines changed

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- Fewer things are considered branches now:
27+
28+
- Lambdas, comprehensions, and generator expressions are no longer marked as
29+
missing branches if they don't complete execution.
2730

2831

2932
.. scriv-start-here

coverage/core.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
from coverage.exceptions import ConfigError
1515
from coverage.pytracer import PyTracer
1616
from coverage.sysmon import SysMonitor
17-
from coverage.types import TFileDisposition, Tracer, TWarnFn
17+
from coverage.types import (
18+
TFileDisposition,
19+
Tracer,
20+
TWarnFn,
21+
)
1822

1923

2024
try:
@@ -45,7 +49,14 @@ class Core:
4549
packed_arcs: bool
4650
systrace: bool
4751

48-
def __init__(self, warn: TWarnFn, timid: bool, metacov: bool) -> None:
52+
def __init__(self,
53+
warn: TWarnFn,
54+
timid: bool,
55+
metacov: bool,
56+
) -> None:
57+
# Defaults
58+
self.tracer_kwargs = {}
59+
4960
core_name: str | None
5061
if timid:
5162
core_name = "pytrace"
@@ -74,14 +85,12 @@ def __init__(self, warn: TWarnFn, timid: bool, metacov: bool) -> None:
7485
self.systrace = False
7586
elif core_name == "ctrace":
7687
self.tracer_class = CTracer
77-
self.tracer_kwargs = {}
7888
self.file_disposition_class = CFileDisposition
7989
self.supports_plugins = True
8090
self.packed_arcs = True
8191
self.systrace = True
8292
elif core_name == "pytrace":
8393
self.tracer_class = PyTracer
84-
self.tracer_kwargs = {}
8594
self.file_disposition_class = FileDisposition
8695
self.supports_plugins = False
8796
self.packed_arcs = False

coverage/env.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ class PYBEHAVIOR:
6464
# 3.7 changed how functions with only docstrings are numbered.
6565
docstring_only_function = (not PYPY) and (PYVERSION <= (3, 10))
6666

67-
# When a break/continue/return statement in a try block jumps to a finally
68-
# block, does the finally jump back to the break/continue/return (pre-3.10)
69-
# to do the work?
70-
finally_jumps_back = (PYVERSION < (3, 10))
71-
72-
# CPython 3.11 now jumps to the decorator line again while executing
73-
# the decorator.
74-
trace_decorator_line_again = (CPYTHON and PYVERSION > (3, 11, 0, "alpha", 3, 0))
75-
7667
# CPython 3.9a1 made sys.argv[0] and other reported files absolute paths.
7768
report_absolute_files = (
7869
(CPYTHON or (PYPY and PYPYVERSION >= (7, 3, 10)))
@@ -112,10 +103,6 @@ class PYBEHAVIOR:
112103
# only a 0-number line, which is ignored, giving a truly empty module.
113104
empty_is_empty = (PYVERSION >= (3, 11, 0, "beta", 4))
114105

115-
# Are comprehensions inlined (new) or compiled as called functions (old)?
116-
# Changed in https://github.com/python/cpython/pull/101441
117-
comprehensions_are_functions = (PYVERSION <= (3, 12, 0, "alpha", 7, 0))
118-
119106
# PEP669 Low Impact Monitoring: https://peps.python.org/pep-0669/
120107
pep669 = bool(getattr(sys, "monitoring", None))
121108

coverage/execfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ def run_python_file(args: list[str]) -> None:
288288

289289
def make_code_from_py(filename: str) -> CodeType:
290290
"""Get source from `filename` and make a code object of it."""
291-
# Open the source file.
292291
try:
293292
source = get_python_source(filename)
294293
except (OSError, NoSource) as exc:
295294
raise NoSource(f"No file to run: '{filename}'") from exc
296295

297-
return compile(source, filename, "exec", dont_inherit=True)
296+
code = compile(source, filename, mode="exec", dont_inherit=True)
297+
return code
298298

299299

300300
def make_code_from_pyc(filename: str) -> CodeType:

0 commit comments

Comments
 (0)