Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix Cython coverage collection in CI#1808

Open
rodrigobnogueira wants to merge 2 commits into
aio-libs:masteraio-libs/yarl:masterfrom
rodrigobnogueira:fix/translate-cython-linetracerodrigobnogueira/yarl:fix/translate-cython-linetraceCopy head branch name to clipboard
Open

Fix Cython coverage collection in CI#1808
rodrigobnogueira wants to merge 2 commits into
aio-libs:masteraio-libs/yarl:masterfrom
rodrigobnogueira:fix/translate-cython-linetracerodrigobnogueira/yarl:fix/translate-cython-linetraceCopy head branch name to clipboard

Conversation

@rodrigobnogueira

@rodrigobnogueira rodrigobnogueira commented Jul 20, 2026

Copy link
Copy Markdown
Member

What do these changes do?

Restore *.pyx coverage collection, which has been broken in two stacked layers.

  1. The translate-cython CLI, which CI runs to regenerate the C files that the Cython.Coverage plugin reads, was building its cythonize arguments without requesting the linetrace directive after Only enable line tracing when building with Cython tracing #1521 made tracing opt-in (while inconsistently still patching the tracing env two lines below). The regenerated C files carried no trace instrumentation, the plugin treated every Cython module as untraceable, and nothing was recorded. The good-to-bad window bisected in the issue contains exactly one commit, and it is Only enable line tracing when building with Cython tracing #1521.
  2. Cython 3.1+ (upgraded later in Use Cython 3.1 universally #1514) routes tracing through sys.monitoring on CPython 3.12+, and those events never reach the plugin, which only works with the coverage.py "ctrace" core that .coveragerc already pins. Traced builds now define CYTHON_USE_SYS_MONITORING=0 to request the legacy tracing hooks.

Each fix is one line in the PEP 517 backend; both were confirmed independently with local A/B runs (details below). The per-job fail_under floor moves from 98.95 to 98: restoring the *.pyx statements to the measured set puts macOS jobs at roughly 98.4 (platform-specific tests are skipped there), and the old floor had been calibrated while those statements were invisible.

Are there changes in behavior for the user?

No. Both changes only affect builds that request Cython line tracing; release wheels are unchanged.

Is it a substantial burden for the maintainers to support this?

No, it is two lines in the existing tracing seam plus a comment.

Related issue number

Fixes #1581. The same two-layer diagnosis likely applies to ansible/pylibssh#781, which shares this backend.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (N/A: build backend wiring; the proof is the coverage report itself, see below)
  • Documentation reflects the changes (N/A: no user-visible docs involved)
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt (N/A: the repo has no such file)
  • Add a new news fragment into the CHANGES/ folder
Verification details (for reviewers)

All runs on CPython 3.13, Cython 3.2.8 (the current pin), coverage 7.x, macOS arm64, with a wheel built with with-cython-tracing=true installed and .coveragerc in effect.

  • Current master, translate-cython output: grep -c __Pyx_TraceLine yarl/_quoting_c.c returns 0. With fix 1: 367.
  • A/B with the same traced extension and only the checkout C file swapped: untraced C file produces no _quoting_c.pyx row in the report; traced C file restores it. This reproduces the exact codecov symptom from the issue (file listed, no data).
  • Fix 2 A/B: with CYTHON_USE_SYS_MONITORING left at its default, no .pyx frames ever reach coverage under the ctrace core; with the define, data flows.
  • CI-shaped end-to-end (wheel install, translate-cython, python -Im pytest tests/test_quoting.py --cov-report=xml): yarl/_quoting_c.pyx present in coverage.xml with 276 of 292 statements hit.
  • Full suite on macOS (1516 passed): overall 98.44 with _quoting_c.pyx at 94.52, which is what sets the new per-job floor; the first CI round confirmed the fix end-to-end (Linux and Windows green with .pyx measured, patch coverage 99.54) and failed only on the stale macOS floor.
  • pre-commit passes on the changed files. make doc-spelling could not run on this machine (no libenchant available); the news fragment keeps all technical terms in RST literals and uses only wordlist-known words otherwise.

The translate-cython step regenerates the C files that the
Cython.Coverage plugin reads, but it stopped requesting the linetrace
directive when line tracing became opt-in in aio-libs#1521, so the plugin saw
untraceable modules and recorded no data for the Cython sources.

Cython 3.1+ also routes tracing through sys.monitoring on CPython
3.12+, which never reaches the plugin; traced builds now define
CYTHON_USE_SYS_MONITORING=0 to request the legacy tracing hooks.
@rodrigobnogueira
rodrigobnogueira force-pushed the fix/translate-cython-linetrace branch from 1b5f065 to f07229d Compare July 20, 2026 00:53
@rodrigobnogueira
rodrigobnogueira marked this pull request as ready for review July 20, 2026 01:01
With the Cython modules back in the measured set, macOS test jobs
bottom out around 98.4 percent because platform-specific tests are
skipped there. The previous 98.95 floor was calibrated during the
period when the *.pyx files were silently absent from measurement.
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Jul 20, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 97 untouched benchmarks


Comparing rodrigobnogueira:fix/translate-cython-linetrace (0a85507) with master (56150c8)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (0b30cb0) during the generation of this report, so 56150c8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Vizonex
Vizonex self-requested a review July 20, 2026 03:55
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (515adca) to head (0a85507).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1808      +/-   ##
==========================================
- Coverage   99.86%   99.54%   -0.33%     
==========================================
  Files          22       23       +1     
  Lines        4570     4865     +295     
  Branches      258      258              
==========================================
+ Hits         4564     4843     +279     
- Misses          3       19      +16     
  Partials        3        3              
Flag Coverage Δ
CI-GHA 99.46% <ø> (-0.32%) ⬇️
OS-Linux 99.46% <ø> (-0.32%) ⬇️
OS-Windows 98.38% <ø> (-0.18%) ⬇️
OS-macOS 98.15% <ø> (-0.61%) ⬇️
Py-3.10 99.42% <ø> (-0.32%) ⬇️
Py-3.11 99.42% <ø> (-0.32%) ⬇️
Py-3.12 99.42% <ø> (-0.32%) ⬇️
Py-3.13 99.42% <ø> (-0.34%) ⬇️
Py-3.14 99.41% <ø> (-0.34%) ⬇️
Py-3.14t 99.41% <ø> (-0.34%) ⬇️
Py-pypy-3.11 99.30% <ø> (+<0.01%) ⬆️
VM-macos-latest 98.15% <ø> (-0.61%) ⬇️
VM-ubuntu-latest 99.46% <ø> (-0.32%) ⬇️
VM-windows-latest 98.38% <ø> (-0.18%) ⬇️
pytest 99.46% <ø> (-0.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Vizonex Vizonex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As someone who enjoys the Cython language a bit more than maybe some other people. I have chosen to review this PR myself. I have added myself to the list of reviewers as a result and I believe adding coverage for Cython would be beneficial. While it is annoying to hit every nook and cranny for testing code I have no complaintss bout this. The comments clearly state what this change is doing for anybody that is confused about this.

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

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TODO] Fix coverage collection for Cython modules

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.