Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support coverage plugins with sys.monitoring #1790

Open
scoder opened this issue May 25, 2024 · 0 comments
Open

Support coverage plugins with sys.monitoring #1790

scoder opened this issue May 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@scoder
Copy link

scoder commented May 25, 2024

Is your feature request related to a problem? Please describe.

Running coverage.py on Cython code with sys.monitoring in Py3.13 disables the Cython coverage plugin:

# Early warning if we aren't going to be able to support plugins.
if self._plugins.file_tracers and not self._collector.supports_plugins:
self._warn(
"Plugin file tracers ({}) aren't supported with {}".format(

Describe the solution you'd like
Plugins should work the same with the old tracing and new monitoring infrastructure.

Additional context
I'm currently working on getting Cython to use the monitoring C-API, but found that coverage.py doesn't support both together as it stands.

@scoder scoder added enhancement New feature or request needs triage labels May 25, 2024
scoder added a commit to scoder/cython that referenced this issue Aug 13, 2024
…upport for these tests.

coverage.py does not (yet?) support sys.monitoring with the Cython plugin yet.
See nedbat/coveragepy#1790
scoder added a commit to cython/cython that referenced this issue Aug 21, 2024
* Change profiling/tracing to line up more with CPython's trace events, including function/generator return value reporting.

* Clean up the ownership of code objects between functions and their def/cpdef wrappers. The code object is now owned by the innermost tree node (wrapper) and used by the outer syntax node (lambda, function). All CFuncDefNodes now have a code object (not just those with Python wrappers) and fused functions use a separate code object for each specialisation.

* Use the code object of the (user facing) generator function also for the generator body (instead of the other way round) since the body has a different signature.

* Fix code object creation for Lambda nodes by moving it after initialising the scope since we need to know the local scope to correctly include args and kwargs.

* Implement exception monitoring and remove the code in pre-monitoring Python versions since it was never actually used.

* Fix 'skip_dispatch' condition for module level cpdef functions.
This was previously always off because it incorrectly reversed the "lookup_module_cpdef" option.

* Enable line tracing for 'pass' statements to avoid coverage lacks.

* Implement support for STOP_ITERATION events, but do not use it for now since it's difficult to find the few cases where CPython triggers it.

* Add trace logger in pstats/monitoring test as debug helper for comparing Python with Cython.

* Trace yields as generator returns in non-monitoring Python versions (<3.13).

* Trace exception returns as regular returns in non-monitoring Python versions (<3.13).

* Use pre sys.monitoring line tracing in Py3.12 and enable coverage testing in Py3.12 with the old tracing infrastructure.

* Enable coverage.py on Py3.13 by disabling the sys.monitoring support for these tests.
coverage.py does not (yet?) support sys.monitoring with the Cython plugin yet.
See nedbat/coveragepy#1790

* Disable tracing tests in PyPy which lacks the entire tracing infrastructure (both old and new).

* Fix a Unicode encoding issue when using the module init function name for tracing and the refnanny.

* Document the user facing C trace macros.

* Implement a "linetable" for CodeObjects as described in PEP-626. This allows the CodeObjects to calculate correct line/column positions when tracing.

* Always report function returns, not just when we have a reportable return value.

* Prevent re-entry into tracing code while running a trace function.

* Test runner: Set PYTHONFAULTHANDLER=1 to enable it also in end-to-end tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants