Skip to content

Warn when sysmon cannot switch dynamic contexts - #2234

Merged
nedbat merged 8 commits into
coveragepy:mainfrom
JSap0914:warn-sysmon-switch-context-2200
Jul 27, 2026
Merged

Warn when sysmon cannot switch dynamic contexts#2234
nedbat merged 8 commits into
coveragepy:mainfrom
JSap0914:warn-sysmon-switch-context-2200

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

What

Add an explicit core capability for dynamic contexts and warn once when switch_context() is used with the sys.monitoring core.

Why

The sysmon core cannot currently honor dynamic context switches. Programmatic calls previously continued silently, which could produce incomplete per-context data without any indication to the caller.

Fixes #2200

Tests

  • COVERAGE_CORE=sysmon python -m pytest -q tests/test_api.py::ApiTest::test_switch_context_sysmon_warning
  • COVERAGE_CORE=ctrace python -m pytest -q tests/test_api.py::SwitchContextTest
  • COVERAGE_CORE=pytrace python -m pytest -q tests/test_api.py::SwitchContextTest
  • HYPOTHESIS_PROFILE=ci tox -q -e py314
  • python -m mypy --python-version=3.14 --strict coverage tests setup.py
  • ruff format --check coverage/control.py coverage/core.py tests/test_api.py
  • python -m pylint --notes= coverage/control.py coverage/core.py tests/test_api.py
  • pre-commit run --files coverage/control.py coverage/core.py tests/test_api.py

@nedbat
nedbat merged commit 153ebe6 into coveragepy:main Jul 27, 2026
72 checks passed
@nedbat

nedbat commented Aug 2, 2026

Copy link
Copy Markdown
Member

This is now released as part of coverage 7.15.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sysmon core silently drops contexts set via switch_context() (no warning, no fallback)

2 participants