Skip to content

Align OS argument conversion and syscall handling with Python 3.15 - #9146

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:split/os-platform-315
Oct 16, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowdot:split/os-platform-315

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Align OS argument conversion and timestamp protocols with CPython 3.15.0, preserving integer/ns semantics from Use 64-bit Windows CRT and FILETIME timestamps #9116.
  • Use raw-descriptor syscall entrypoints for Python-supplied descriptors; support Linux sendfile(offset=None), checked macOS headers/trailers and flags, canonical partial-success errors, and signal-aware EINTR retries.
  • Add the Python-facing ftruncate/truncate audit events with canonical conversion ordering, retain Windows CRT errno handling, and update getlogin decoding/errno, Linux GNU NODEV, WASI chmod validation and fork-warning propagation.
  • Import os.py and the final test_os package directly with update_lib from CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve all five current test guards; retire the two legacy test modules through the reviewed package mapping.

Rebased onto main at 9e18d7be6b90cec1fa01429a2955f1623dd53d4c, preserving the merged #9142 updater behavior. The CI repair adds six canonical test.support lines through an actual update_lib migrate invocation pinned to CPython d220409a13b77de7a6c30abe16ea90db01528edc: three root-user decorator assignments and two export names. Unrelated existing support helpers and customizations remain intact. The existing updater and its tests gain a narrowly scoped, hash-pinned selective test.support import mode with dependency and mode-conflict checks.

This PR excludes closerange (#9031), mmap (#9141), getpath/sysconfig/venv and test_io changes.

Validation

Independent source/integration review and normal commit hooks passed.

Current rebased head 948ebad7a7e6be094e63445fc13a9870527172de:

  • All 238 updater host tests passed, including selective imports and unchanged preservation/default modes.
  • A fresh matching narrow release build passed (threading,stdlib,stdio,importlib,host_env).
  • Strict release Clippy passed for host_env and VM, all targets, with warnings denied.
  • A bounded native import gate passed for test.support and the canonical test.test_os.test_os module, checking the imported helpers and root/non-root decorator flags/reasons in a non-root environment. Zero test bodies, loaders or fixtures were run.
  • The exact copied binary, full source/Lib hashes, cache absence and loaded module origins were verified. The import ran with private cwd/TMP/cache and time/resource limits; its capability probes include disposable files/symlinks/xattrs, a localhost IPv6 bind and password-database enumeration.

Historical focused runtime coverage on the original head 3f91766266469f922b44b32dbcbe630dbff591db:

  • Nine fresh bounded canonical invocations: eight passed; getlogin skipped with ENOTTY because the environment has no login terminal. This is not validated login behavior.
  • Complete source/Lib hashes, cache checks and module origins were verified before/after each case.
  • Six test_os cases used AST-identical extracted methods/helpers and setup/cleanup rather than importing unrelated socket capability probes. Three PosixTester cases used the canonical leaf module.

Those historical OS cases were not rerun on the rebased head. No broad OS suite, root-account execution or cross-platform local validation is claimed.

Remaining differences and coverage limits

  • Mutable sendfile buffers are snapshotted after argument/exporter conversion using RustPython's existing unlocked-buffer mechanism. CPython observes live buffers, so concurrent mutation semantics are not claimed identical.
  • Shared integer overflow messages still name Rust primitive types. Pathname truncate still uses open/set_len, retaining existing permission/race/negative-length differences. The internal FileIO borrowed-descriptor helper remains unchanged.
  • getlogin still copies libc's non-reentrant storage. Fork warnings occur after child creation; warning-as-error can hide the returned child/master descriptor, as in final CPython's ordering.
  • No local signal injection, fork, concurrent mutation, invalid-FD or full sendfile fixture tests were run. macOS/Windows/WASI paths require hosted validation. An environment-dependent getlogin skip is reported separately from passes.

@coderabbitai

coderabbitai Bot commented Oct 15, 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: 671c7e2b-a7c7-47ed-a965-79f9e8df7e1c
📥 Commits

Reviewing files that changed from the base of the PR and between 9e18d7b and 948ebad.

⛔ Files ignored due to path filters: 7
  • Lib/os.py is excluded by !Lib/**
  • Lib/test/support/__init__.py is excluded by !Lib/**
  • Lib/test/test_os/__init__.py is excluded by !Lib/**
  • Lib/test/test_os/test_os.py is excluded by !Lib/**
  • Lib/test/test_os/test_posix.py is excluded by !Lib/**
  • Lib/test/test_os/test_windows.py is excluded by !Lib/**
  • Lib/test/test_os/utils.py is excluded by !Lib/**
📒 Files selected for processing: 7
  • crates/host_env/src/crt_fd.rs
  • crates/host_env/src/posix.rs
  • crates/vm/src/stdlib/os.rs
  • crates/vm/src/stdlib/posix.rs
  • crates/vm/src/stdlib/posix_compat.rs
  • scripts/update_lib/cmd_migrate.py
  • scripts/update_lib/tests/test_migrate.py
+-------------------------------------------------------+
| Once upon a dream, I found all the bugs in your code. |
+-------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      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.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
[x] lib: cpython/Lib/os.py
[x] test: cpython/Lib/test/test_popen.py

dependencies:

  • os

dependent tests: (186 tests)

  • os: test___all__ test__osx_support test_argparse test_asdl_parser test_ast test_asyncio test_atexit test_base64 test_baseexception test_bdb test_bool test_buffer test_builtin test_bytes test_bz2 test_c_locale_coercion test_calendar test_clinic test_cmd_line test_cmd_line_script test_codecs test_compile test_compileall test_concurrent_futures test_configparser test_contextlib test_ctypes test_dbm test_dbm_dumb test_dbm_sqlite3 test_decimal test_devpoll test_doctest test_dtrace test_eintr test_embed test_ensurepip test_enum test_epoll test_exception_hierarchy test_exceptions test_external_inspection test_faulthandler test_fcntl test_file test_file_eintr test_filecmp test_fileinput test_fileio test_fileutils test_float test_fnmatch test_fork1 test_fractions test_fstring test_ftplib test_future_stmt test_generated_cases test_genericalias test_genericpath test_getpass test_gettext test_glob test_graphlib test_gzip test_hash test_hashlib test_http_cookiejar test_httplib test_httpservers test_imaplib test_importlib test_inspect test_io test_ioctl test_json test_kqueue test_largefile test_launcher test_linecache test_locale test_logging test_lzma test_mailbox test_marshal test_math test_mimetypes test_mmap test_modulefinder test_msvcrt test_multiprocessing_main_handling test_netrc test_ntpath test_openpty test_optparse test_os test_pathlib test_pdb test_peg_generator test_perfmaps test_pkg test_pkgutil test_platform test_plistlib test_poll test_popen test_poplib test_posix test_posixpath test_profile test_pstats test_pty test_py_compile test_pydoc test_pyexpat test_pyrepl test_random test_regrtest test_repl test_reprlib test_robotparser test_runpy test_sax test_script_helper test_selectors test_shelve test_shlex test_shutil test_signal test_site test_smtpnet test_socket test_socketserver test_sqlite3 test_ssl test_stat test_string_literals test_strptime test_structseq test_subprocess test_support test_sys test_sys_settrace test_sysconfig test_tabnanny test_tarfile test_tempfile test_termios test_thread test_threading test_threadsignals test_time test_tokenize test_tools test_trace test_tracemalloc test_tty test_turtle test_typing test_unicode_file test_unicode_file_functions test_unittest test_univnewlines test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_uuid test_venv test_wait3 test_wait4 test_wave test_webbrowser test_winapi test_winconsoleio test_winreg test_winsound test_wsgiref test_xml_etree test_xpickle test_zipfile test_zipimport test_zipimport_support test_zoneinfo test_zstd

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Import canonical os tests through update_lib, retaining existing guards. Preserve raw descriptor validation, errno, audit ordering, signal retries and unlocked sendfile buffers.

Validation: independent source review passed; matching release build and nine bounded canonical cases pending.

Assisted-by: OpenAI Codex:model version unavailable
Add hash-pinned selective assignment migration within test.support and import the three Python 3.15.0 privilege helpers plus their public exports. Preserve unrelated support helpers and existing test markers.

Validation: 177 host updater tests pass; byte-identical canonical helper provenance verified. Independent source review passed. Native import validation pending integration onto current main.

Assisted-by: OpenAI Codex:model version unavailable
@youknowdot
youknowdot force-pushed the split/os-platform-315 branch from 3f91766 to 948ebad Compare October 15, 2026 11:20
@youknowone
youknowone marked this pull request as ready for review October 16, 2026 01:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T01:17:06.472064Z 948ebad 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 1f4e9ff into RustPython:main Oct 16, 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: 948ebad7a7

ℹ️ 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".

if count > i32::MAX as usize {
return Err(vm.new_overflow_error(format!("sendfile() {kind} is too large")));
}
let mut v = Vec::with_capacity(count);

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 Reserve sendfile sequence capacity fallibly

On macOS, a custom headers or trailers sequence whose __len__ reports a huge value (up to i32::MAX) reaches this allocation before any __getitem__ call. Vec::with_capacity handles allocation failure through Rust's OOM path, which aborts the interpreter, so even a sequence that would immediately raise IndexError can terminate the process instead of producing MemoryError or its normal exception; reserve fallibly and map failure to vm.no_memory_error().

Useful? React with 👍 / 👎.

from .utils import create_file


class Win32KillTests(unittest.TestCase):

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 Preserve the removed Windows error tests

When running the suite on Windows, the split into this new module omits the parent revision's entire Win32ErrorTests class (test_rename, test_remove, test_chdir, test_mkdir, test_utime, and test_chmod); a repo-wide search under Lib/test/test_os confirms that class was not relocated. Preserve those bodies in test_windows.py so the package migration does not delete platform-specific test logic, which the repository explicitly forbids.

AGENTS.md reference: AGENTS.md:L276-L282

Useful? React with 👍 / 👎.



def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the OS test dependency after the package move

With the OS tests now represented by this package, DEPENDENCIES["os"]["test"] in scripts/update_lib/deps.py:689-693 still names test_os.py. get_test_paths() gives that explicit entry priority, and cmd_quick.py:415-418 warns and skips it when absent, so the next quick update of Lib/os.py will update test_popen.py but leave this entire package stale; change the dependency entry to test_os.

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