Fix sysmon arcs for single-line class bodies by itscloud0 · Pull Request #2207 · coveragepy/coveragepy · GitHub
Skip to content

Fix sysmon arcs for single-line class bodies#2207

Open
itscloud0 wants to merge 1 commit into
coveragepy:mainfrom
itscloud0:fix-2167-single-line-class-branch
Open

Fix sysmon arcs for single-line class bodies#2207
itscloud0 wants to merge 1 commit into
coveragepy:mainfrom
itscloud0:fix-2167-single-line-class-branch

Conversation

@itscloud0

@itscloud0 itscloud0 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • fix sysmon arc tracking for single-line class bodies followed by more code
  • keep per-thread frame state across line, resume, return, and yield events
  • add a regression covering class Foo: ... followed by pass

Problem

With Python 3.14 and the sysmon core, coverage reports a missing branch for a single-line class followed by another statement:

class Foo: ...

pass

On main, this reports a missing 1->3 branch even though the class definition is fully covered. ctrace does not misreport it.

Solution

sys.monitoring line events were recording self-arcs and losing the previous traced line for active frames. This patch keeps per-thread frame state for traced frames and uses it to record arcs between successive lines and function exit. It also handles PY_RESUME and PY_YIELD so paused frames do not corrupt later arc reporting.

@itscloud0 itscloud0 marked this pull request as ready for review June 27, 2026 05:07
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.

1 participant