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

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.

@webknjaz

webknjaz commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

xref also mentioned in the pytest plugin where the warning leaks with insufficient context as is: pytest-dev/pytest-cov#755


Search string for people from search engines:

Dynamic contexts aren't supported with core=sysmon; context data may be incomplete (no-sysmon-context); see https://coverage.readthedocs.io/en/7.15.3/messages.html#warning-no-sysmon-context

webknjaz added a commit to re-actors/alls-green that referenced this pull request Aug 21, 2026
This will allow correct coverage collection with dynamic coverage
enabled and will avoid warnings that coveragepy v7.15.3 started emitting
and our configuration is turning into hard errors.

* aio-libs/multidict#1393
* pytest-dev/pytest-cov#755
* https://coverage.rtfd.io/en/latest/changes.html#version-7-15-3-2026-08-02
* coveragepy/coveragepy#2200
* coveragepy/coveragepy#2234
webknjaz added a commit to ansible/awx_plugins.interfaces that referenced this pull request Sep 14, 2026
This will allow correct coverage collection with dynamic coverage
enabled and will avoid warnings that coveragepy v7.15.3 started emitting
and our configuration is turning into hard errors.

* aio-libs/multidict#1393
* pytest-dev/pytest-cov#755
* https://coverage.rtfd.io/en/latest/changes.html#version-7-15-3-2026-08-02
* coveragepy/coveragepy#2200
* coveragepy/coveragepy#2234

Signed-off-by: Sviatoslav Sydorenko <[email protected]>
github-actions Bot added a commit to step-security/alls-green that referenced this pull request Sep 24, 2026
This will allow correct coverage collection with dynamic coverage
enabled and will avoid warnings that coveragepy v7.15.3 started emitting
and our configuration is turning into hard errors.

* aio-libs/multidict#1393
* pytest-dev/pytest-cov#755
* https://coverage.rtfd.io/en/latest/changes.html#version-7-15-3-2026-08-02
* coveragepy/coveragepy#2200
* coveragepy/coveragepy#2234
Raj-StepSecurity pushed a commit to step-security/alls-green that referenced this pull request Sep 24, 2026
This will allow correct coverage collection with dynamic coverage
enabled and will avoid warnings that coveragepy v7.15.3 started emitting
and our configuration is turning into hard errors.

* aio-libs/multidict#1393
* pytest-dev/pytest-cov#755
* https://coverage.rtfd.io/en/latest/changes.html#version-7-15-3-2026-08-02
* coveragepy/coveragepy#2200
* coveragepy/coveragepy#2234
webknjaz added a commit to tox-dev/tox-pre-commit that referenced this pull request Oct 2, 2026
This will allow correct coverage collection with dynamic coverage
enabled and will avoid warnings that coveragepy v7.15.3 started emitting
and our configuration is turning into hard errors.

* aio-libs/multidict#1393
* pytest-dev/pytest-cov#755
* https://coverage.rtfd.io/en/latest/changes.html#version-7-15-3-2026-08-02
* coveragepy/coveragepy#2200
* coveragepy/coveragepy#2234

Signed-off-by: Sviatoslav Sydorenko <[email protected]>
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)

3 participants