Skip to content

Reject NaN when manually advancing MockClock - #3585

Closed
Vmnebula wants to merge 1 commit into
python-trio:mainfrom
Vmnebula:fix/mock-clock-jump-nan
Closed

Vmnebula wants to merge 1 commit into
python-trio:mainfrom
Vmnebula:fix/mock-clock-jump-nan

Conversation

@Vmnebula

Copy link
Copy Markdown

Fixes #3578.

A NaN jump permanently corrupts MockClock's virtual time, so subsequent valid jumps cannot recover it. Reject NaN before modifying the clock, while retaining the existing negative-jump error and zero/positive-jump behavior.

Adds regression coverage for stationary and advancing clocks, verifies that rejection preserves the time and permits later valid jumps, and updates the documented exception and release note.

Verification

  • New regressions on unchanged upstream: 2 failed (missing ValueError).
  • Mock-clock tests including slow tests: 9 passed.
  • Default source test suite: 829 passed, 72 skipped, 2 xfailed.
  • mypy --platform linux src/trio: passed, 144 source files.
  • Changed-file repository pre-commit checks: passed, including Black, Ruff, spelling and Sphinx lint.
Broader checks and local limitations (Python 3.12.3, Linux)

The full slow suite produced 876 passed, 23 skipped, 2 xfailed and 2 failures. Both failures are existing test_static_tool_sees_class_members cases for Jedi/Mypy reporting trio.WindowsPath.ntpath; reproduced unchanged on a clean upstream worktree at 93e6b2e.

The repository-wide Mypy command including docs encounters an existing docs/source/conf.py:285 Sphinx inventory typing error, also reproduced on that clean upstream worktree. Library/source Mypy passes with the repository's default Python 3.10 target.

AI-assisted implementation and local verification; no separate human review is claimed.

A NaN jump permanently corrupts the virtual clock and makes later valid jumps ineffective. Reject it before changing the clock state, matching the validation already applied to MockClock.rate.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (93e6b2e) to head (136ed99).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3585   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19555        19571   +16     
  Branches         1330         1331    +1     
===============================================
+ Hits            19555        19571   +16     
Files with missing lines Coverage Δ
src/trio/_core/_mock_clock.py 100.00000% <100.00000%> (ø)
src/trio/_core/_tests/test_mock_clock.py 100.00000% <100.00000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CoolCat467 CoolCat467 added the LLM Slop Entirely generated by a large language model with little or no human oversight label Nov 10, 2026
@A5rocks

A5rocks commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

#3579 (comment)

@A5rocks A5rocks closed this Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM Slop Entirely generated by a large language model with little or no human oversight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MockClock.jump() accepts NaN and corrupts the clock

4 participants