Skip to content

Commit cfda516

Browse files
committed
fix: fewer warnings, default to sys.monitoring on 3.14+
Don't emit no-ctracer warnings on Python versions where we don't ship compiled wheels.
1 parent 18aa074 commit cfda516

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

coverage/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@ def __init__(
8686
core_name = None
8787

8888
if core_name is None:
89-
# Someday we will default to sysmon, but it's still experimental:
90-
# if not reason_no_sysmon:
91-
# core_name = "sysmon"
92-
if CTRACER_FILE:
89+
if env.SYSMON_DEFAULT and not reason_no_sysmon:
90+
core_name = "sysmon"
91+
elif CTRACER_FILE:
9392
core_name = "ctrace"
9493
else:
95-
if env.CPYTHON and IMPORT_ERROR:
94+
if IMPORT_ERROR and env.SHIPPING_WHEELS:
9695
warn(f"Couldn't import C tracer: {IMPORT_ERROR}", slug="no-ctracer", once=True)
9796
core_name = "pytrace"
9897

coverage/env.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
# Do we have a GIL?
4444
GIL = getattr(sys, '_is_gil_enabled', lambda: True)()
4545

46+
# Do we ship compiled coveragepy wheels for this version?
47+
SHIPPING_WHEELS = CPYTHON and PYVERSION[:2] <= (3, 13)
48+
49+
# Should we default to sys.monitoring?
50+
SYSMON_DEFAULT = CPYTHON and PYVERSION >= (3, 14)
51+
4652
# Python behavior.
4753
class PYBEHAVIOR:
4854
"""Flags indicating this Python's behavior."""

tests/test_process.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,11 +1133,12 @@ def test_core_default(self) -> None:
11331133
self.make_file("numbers.py", "print(123, 456)")
11341134
out = self.run_command("coverage run --debug=sys numbers.py")
11351135
assert out.endswith("123 456\n")
1136-
core = re_line(r" core:", out).strip()
1137-
# if env.PYBEHAVIOR.pep669:
1138-
# assert core == "core: SysMonitor"
11391136
warns = re_lines(r"\(no-ctracer\)", out)
1140-
if self.has_ctracer:
1137+
core = re_line(r" core:", out).strip()
1138+
if env.SYSMON_DEFAULT:
1139+
assert core == "core: SysMonitor"
1140+
assert not warns
1141+
elif self.has_ctracer:
11411142
assert core == "core: CTracer"
11421143
assert not warns
11431144
else:

0 commit comments

Comments
 (0)