◐ Shell
clean mode source ↗

Update os from v3.14.2 and fix nt,posix,_os by youknowone · Pull Request #6958 · RustPython/RustPython

📝 Walkthrough

Walkthrough

Socket timeout APIs now accept optional float args via the VM; float→Duration conversion tightened; runtime warnings added for bool used as file descriptors; ScandirIterator gains a destructor and readinto added; link and spawn/path handling moved to FsPath/OsPath with a new _create_environ; Windows env dedupe; SIGBREAK added on Windows.

Changes

Cohort / File(s) Summary
Socket timeout & ArgIntoFloat
crates/stdlib/src/socket.rs
settimeout/setdefaulttimeout signatures changed to accept Option<ArgIntoFloat> + &VirtualMachine, validate NaN/out-of-range, map errors via VM, and use sentinel for None.
Float→Duration conversion
crates/vm/src/convert/try_from.rs
Added NaN/finite/overflow checks; replaced from_secs_f64 with explicit trunc+fraction → secs/nanos construction and explicit overflow/error returns.
Bool-as-FD warnings / fd conversions
crates/vm/src/ospath.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/posix.rs
Introduced warn_if_bool_fd and emit RuntimeWarning when a Python bool is used as a file descriptor; integrated into DirFd/BorrowedFd/TryFromObject conversion sites.
OS module: iterator destructor, readinto, link refactor
crates/vm/src/stdlib/os.rs
Added ScandirIterator Destructor (emits ResourceWarning on unclosed iterator), added readinto(fd, buffer, vm), introduced LinkArgs and refactored link to accept it; adjusted truncate/link follow_symlinks behavior.
Env, spawn & path handling (FsPath/OsPath)
crates/vm/src/stdlib/nt.rs, crates/vm/src/stdlib/posix.rs
Added _create_environ(vm); switched argv/path/env conversions to FsPath/OsPath flows (replacing inline PyStr extraction); moved sched_param items into new posix_sched submodule.
Windows env assembly dedupe
crates/vm/src/stdlib/winapi.rs
getenvironment now deduplicates environment variables case-insensitively (last-wins), sorts entries, and assembles the final wide-string output per-entry.
Signal: SIGBREAK on Windows
crates/vm/src/stdlib/signal.rs
Added exported Windows-only SIGBREAK = 21 and integrated it into signal(), strsignal(), valid_signals(), and raise_signal() paths.
Imports / public API adjustments
various files
Added/updated public functions/types and imports: ArgIntoFloat, warn_if_bool_fd, LinkArgs, _create_environ, readinto, ScandirIterator Destructor, and new posix_sched submodule exposure.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • ShaharNaveh
  • fanninpm
  • coolreader18

Poem

"🐇 I hopped through timeouts, turned floats to ticks,
I warned at bool‑FDs with soft, tiny clicks.
I closed scandir when the iterator's done,
Tidied envs and links — one by one.
SIGBREAK drums a cheerful little drum."

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and uses abbreviated module names (nt, posix, _os) without clearly conveying the primary changes being made. Clarify the title to describe the main purpose of the update—e.g., 'Add environ handling and file descriptor warnings to os module' or 'Refactor os/nt/posix modules for path-like and validation improvements'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 93.88% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.