Skip to content

Honor freeze requests during active time travel - #1062

Open
FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/freeze-active-time-travel-20261020
Open

FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/freeze-active-time-travel-20261020

Conversation

@FanWu-ai

Copy link
Copy Markdown
Contributor

The freeze=True flag is ignored by travel() and travel_to() once a ticking trip has already started. For example:

import pendulum

pendulum.travel_to(pendulum.datetime(2024, 1, 1))
pendulum.travel(days=1, freeze=True)
# Time continues advancing instead of staying frozen.
pendulum.travel_back()

_start() returns immediately for an active traveller, so its freeze argument never reaches time-machine. Pass tick=False to move_to() when freezing is requested. Otherwise pass None to retain the current ticking/frozen state, preserving the existing freeze(); travel(...) behavior.

Add 16 deterministic regression/control cases covering fresh, ticking and frozen travellers, both travel methods, repeated moves, restarting after travel_back(), chaining and nested independent traveller contexts. The new tests advance time-machine's real-clock source explicitly rather than waiting for wall-clock time. Document that freezing also applies to an active trip and that subsequent moves retain the frozen state.

Validation on Linux x86_64 / CPython 3.12.14:

  • Pristine complete suite: 1,871 passed, 3 skipped with the Rust extension, and the same with PENDULUM_EXTENSIONS=0.
  • Final regression file against pristine source: 6 failed, 14 passed with each backend.
  • Fixed complete source and clean installed release-wheel suites: 1,887 passed, 3 skipped with each backend. Native-extension loading verified.
  • mypy: passed over 228 source files.
  • prek run --all-files: all six hooks passed, including Rust formatting and clippy.
  • mkdocs build --strict -f docs/mkdocs.yml: passed with six existing informational anchor notices.
  • Release wheel and source distribution built; twine check --strict passed. All 122 production Python files in both artifacts match the tested checkout byte-for-byte.
  • Independent automated verification: 5,120 chained freeze transitions and 1,024 restart controls passed.

The three existing skips cover one Windows-only test and two unsupported POSIX transition cases. Existing checks and their configuration are unchanged. Other Python versions and operating systems have not been tested locally; hosted CI is not claimed passed.

Prepared and tested with OpenAI Codex assistance, including automated review. No human review is claimed.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 19, 2026 22:05
@codspeed

codspeed Bot commented Oct 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

✅ 1 untouched benchmark


Comparing FanWu-ai:fix/freeze-active-time-travel-20261020 (9d6a0e0) with master (e06dace)

Open in CodSpeed

This branch has not been deployed

No deployments
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