Skip to content

Commit cbb7f57

Browse files
committed
wip
1 parent 5f01252 commit cbb7f57

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

coverage/control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _init_for_start(self) -> None:
534534

535535
self._core = Core(
536536
warn=self._warn,
537-
timid=self.config.timid,
537+
config=self.config,
538538
metacov=self._metacov,
539539
)
540540
self._collector = Collector(

coverage/core.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any
1111

1212
from coverage import env
13+
from coverage.config import CoverageConfig
1314
from coverage.disposition import FileDisposition
1415
from coverage.exceptions import ConfigError
1516
from coverage.misc import isolate_module
@@ -52,16 +53,9 @@ class Core:
5253
packed_arcs: bool
5354
systrace: bool
5455

55-
def __init__(self,
56-
warn: TWarnFn,
57-
timid: bool,
58-
metacov: bool,
59-
) -> None:
60-
# Defaults
61-
self.tracer_kwargs = {}
62-
56+
def __init__(self, warn: TWarnFn, config: CoverageConfig, metacov: bool) -> None:
6357
core_name: str | None
64-
if timid:
58+
if config.timid:
6559
core_name = "pytrace"
6660
else:
6761
core_name = os.getenv("COVERAGE_CORE")
@@ -79,9 +73,11 @@ def __init__(self,
7973
else:
8074
core_name = "pytrace"
8175

76+
self.tracer_kwargs = {}
77+
8278
if core_name == "sysmon":
8379
self.tracer_class = SysMonitor
84-
self.tracer_kwargs = {"tool_id": 3 if metacov else 1}
80+
self.tracer_kwargs["tool_id"] = 3 if metacov else 1
8581
self.file_disposition_class = FileDisposition
8682
self.supports_plugins = False
8783
self.packed_arcs = False

coverage/env.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ class PYBEHAVIOR:
159159
# PEP649 and PEP749: Deferred annotations
160160
deferred_annotations = (PYVERSION >= (3, 14))
161161

162+
# Does sys.monitoring support BRANCH_TAKEN?
163+
branch_taken = (
164+
pep669 and
165+
hasattr(sys.monitoring.events, "BRANCH_TAKEN") # type:ignore[attr-defined]
166+
)
167+
162168

163169
# Coverage.py specifics, about testing scenarios. See tests/testenv.py also.
164170

coverage/sysmon.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
cast,
2525
)
2626

27+
from coverage import env
2728
from coverage.debug import short_filename, short_stack
2829
from coverage.misc import isolate_module
2930
from coverage.types import (
@@ -356,8 +357,9 @@ def sysmon_py_start(self, code: CodeType, instruction_offset: int) -> MonitorRet
356357
#
357358
| events.PY_RESUME
358359
# | events.PY_YIELD
359-
| events.LINE,
360-
# | events.BRANCH
360+
| events.LINE
361+
| events.BRANCH_TAKEN
362+
| events.BRANCH_NOT_TAKEN
361363
# | events.JUMP
362364
)
363365
self.local_event_codes[id(code)] = code

0 commit comments

Comments
 (0)