Skip to content

Use 64-bit Windows CRT and FILETIME timestamps - #9116

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/windows-crt-time64
Oct 14, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/windows-crt-time64

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Split the Windows timestamp-width correction out of #8954, preserving current main's negative FILETIME fallback and historical timezone-offset handling.

  • Use libc::time64_t consistently for explicit _gmtime64_s, _localtime64_s, _mktime64, and _time64 calls and their VM/datetime consumers. libc 0.2.189 can define time_t as i32 on x86 Windows GNU.
  • Preserve 64-bit seconds through Windows FILETIME stat conversion helpers and all four timestamp fields, removing narrowing casts in the stat/scandir producers.
  • Add bounded Windows-only 2040 regressions for integer/float UTC calendar conversions and stat/fstat/scandir timestamps on one temporary file. Existing tests, nanosecond handling, error mapping, musl annotations, and datetime fold probing remain intact.

No Lib changes, pytime migration, profiler/sleep changes, or os.utime implementation changes.

Validation

Rebased without patch changes onto main 016ed92f9 (including #9117) after the previous head encountered the shared malachite 0.13/0.14 example-build failure. Current head: a94fc72537124b75c8168f121e14c04384f78e35. git range-diff confirms the same eight-file patch; no #9118 changes were cherry-picked. Both Windows host_env compile checks were rerun successfully after rebase. Linux check/Clippy results below belong to the pre-rebase head 399379064; full Linux checks were not repeated for this patch-identical rebase.

  • Passed independent source review, cargo fmt --all --check, git diff --check, and normal repository commit hooks.
  • Passed cargo check --locked -p rustpython-host_env --no-default-features for both i686-pc-windows-gnu and x86_64-pc-windows-gnu, using official stable rustup targets.
  • The same i686 check on base 28393e932 reproduced four timestamp-width compile errors; all four are resolved by this split.
  • Passed Linux cargo check --locked -p rustpython-host_env -p rustpython-vm -p rustpython-stdlib with default package features.
  • Passed Linux cargo clippy --locked -p rustpython-host_env -p rustpython-vm -p rustpython-stdlib with no warnings.

Windows checks above are compile-only: no Windows linking or runtime testing was performed, and the new Windows-gated regressions have not run locally. Full Windows VM/stdlib cross-compilation requires a C/assembly toolchain for mandatory dependencies that is not installed here. Linux checks do not validate Windows-only code. Full workspace/C-API tests and Python regression suites were not run locally. Keeping this draft pending Windows CI/runtime validation.

Exact source comparison with #9110 head efaf621d found no overlapping nt.rs hunks; no changes were imported from that PR.

AI assistance

OpenAI Codex implemented and independently source-reviewed this split, prepared regression tests, and performed the automated checks listed above. No human manual testing is claimed.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47fc6353-43ad-457f-8d78-5da6483ad8fc
📥 Commits

Reviewing files that changed from the base of the PR and between 016ed92 and a94fc72.

📒 Files selected for processing: 8
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/nt.rs
  • crates/host_env/src/time.rs
  • crates/stdlib/src/_datetime.rs
  • crates/vm/src/stdlib/time.rs
  • extra_tests/snippets/stdlib_datetime.py
  • extra_tests/snippets/stdlib_os.py
  • extra_tests/snippets/stdlib_time.py
 ___________________________________________________________
< Patience, young padawan. The bugs will reveal themselves. >
 -----------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Use the explicit 64-bit CRT ABI regardless of libc time_t width, and preserve 64-bit FILETIME seconds throughout stat producers and consumers. Add bounded Windows regressions for 2040 calendar and stat conversions while retaining existing historical timestamps and error behavior.

AI assistance: OpenAI Codex implemented and independently source-reviewed this split, prepared bounded Python regressions and performed cross-target compile checks. Windows runtime and human manual testing are not claimed.

Assisted-by: OpenAI Codex:model version unavailable
@youknowdot
youknowdot force-pushed the fix/windows-crt-time64 branch from 3993790 to a94fc72 Compare October 14, 2026 13:00
@codspeed

codspeed Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix/windows-crt-time64 (a94fc72) with main (0816af6)2

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (016ed92) during the generation of this report, so 0816af6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@youknowone
youknowone marked this pull request as ready for review October 14, 2026 15:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T16:03:18.242061Z a94fc72 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@youknowone
youknowone merged commit 1b20f6a into RustPython:main Oct 14, 2026
29 of 30 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a94fc72537

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

assert os.name == "posix" or os.name == "nt"


def windows_stat_preserves_time64():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the prohibited snippet-test additions

The new windows_stat_preserves_time64 function adds fresh assertions and test logic to an existing test file, as do test_windows_time64 in stdlib_datetime.py and the new Windows block in stdlib_time.py; repository policy limits test-file changes to adding or removing expected-failure markers, so these regression additions need to be removed or relocated before this patch can comply.

AGENTS.md reference: AGENTS.md:L275-L279

Useful? React with 👍 / 👎.

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.

2 participants