Repository navigation
test(protocols): keep the #1889 spin's first raise inside its try (#1897) - #1901
Conversation
|
Verdict: NEEDS CHANGES at Everything else the Sonnet cross-review checked holds:
|
) - Wait in `_Spin.wait`, called from inside the `try` that drops a raise. On CPython 3.13 the backward jump closing the inline loop sat outside that `except`'s range, so a SIGALRM handled there went straight through and nothing was dropped: the `0 != 1` on CI. - Hold the deadline's own `signal.alarm` back until `wait` arms it, through `_Spin.alarm` and a new `spin_roundtrip` helper. Armed on entry, a stall of a second before the `try` delivered the raise outside it as well. - `clear` now drops the held deadline rather than cancelling the alarm. - Check the swallow outcome in one comparison that also shows the status and the seconds armed. - Add a test that raises at the spin's first backward jump through `sys.monitoring` (CPython 3.12+), and one that stalls before the spin. Closes #1897
61230f4 to
a22a43c
Compare
|
Verdict: GOOD TO GO at A Sonnet re-check found the new wording accurate in the docstrings, the PR body and the commit message:
The re-check confirmed the jump offsets with This PR's
|
|
Coverage: 90.07% (unit tier, Python 3.15,
Per-file detail: the |
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change. Narrow runs only, listed below.Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseThe fix is in the test harness.
examples/generators/options.pybehaves correctly in both cases below.The CI failure, on CPython 3.13: the backward jump closing
_Spin's inline loop falls outside itsexcept TimeoutErrorrange in the exception table. A SIGALRM handled at that jump went straight past the swallow, so the case was stillTIMEOUTbutswallowedstayed 0. 3.12's table has the same gap, but an alarm handled at that jump there resumes inside thetry, so only 3.13 fails naturally; 3.14 and 3.15 cover the jump. The spin now waits in_Spin.wait, called from inside thetry.A stall before the
try: the deadline armed on entry, so a one-second stall before the spin delivered the raise outside it.spin_roundtripnow holds back the deadline's own firstsignal.alarmuntilwaitarms it. Re-arms and the final cancel still reach the real alarm.New tests: one raises at the spin's first backward jump through
sys.monitoring(CPython 3.12+), and one stalls before the spin. Each fails with its part of the fix reverted.Loops of the target test, 200 runs each:
tests/project,tests/test_support_helpers.pyand the tier guard pass.Closes #1897