Skip to content

Support directory descriptors in chmod - #9054

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-chmod-directory-descriptors
Oct 10, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix-chmod-directory-descriptors

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Extract the independent Unix chmod(dir_fd=...) support from #8954 (43065e79ddc46eafeca58cb39398ac007b5d25f7) onto Python 3.14 main (3af5f8a15314446d2b28a90e429c938dc7b8beeb).

  • Route relative directory-descriptor operations through the existing host fchmodat wrapper and report the implemented fd/dir_fd capabilities.
  • Preserve filename-bearing OS errors and CPython's nofollow unsupported-error distinctions.
  • Use a chmod-local signed C-int converter, so absolute paths can ignore negative directory descriptors as CPython does, without constructing an invalid borrowed descriptor or changing shared converters.
  • Preserve merged Give os.chmod a valid __text_signature__ and keyword arguments #8968's signature, existing integer-path fchmod dispatch, macOS/BSD lchmod dispatch, and Redox fallback. Windows and WASI paths are unchanged.

Reference: CPython 3.14.7 chmod implementation and capability construction. Source and runtime agree that successfully parsed dir_fd/follow_symlinks values are ignored for an integer path in 3.14, despite contradictory docstring wording; this patch preserves that behavior. Existing mode parsing and broader unrelated chmod differences are not rewritten.

Current open/merged searches found no dedicated duplicate. #8968 and the earlier integer-fd support remain intact. No host dependency or shared conversion changes are required.

Validation

  • Exact CPython 3.14.7 and this native head pass the newly added function from the existing os snippet. Unchanged main fails its capability assertion.
  • All 17 bounded reference/native cases match exactly, including negative C-int endpoints, relative EBADF/filename, nofollow results, integer-path combinations, bool warnings, overflow diagnostics and index exceptions.
  • Six unchanged canonical chmod tests pass in a fresh private working directory, including TestPosixDirFd.test_chmod_dir_fd, file/directory/fd and symlink cases.
  • Existing builtin_signature.py passes unchanged.
  • Every chmod probe targets only freshly created private temporary files, directories, symlinks or owned descriptors. The broader os snippet and POSIX suite were not run locally because they contain unrelated actions; no assertions or skip markers were weakened.
  • Independent source audit, normal repository hooks, VM Clippy and separate C-API Clippy pass.

Native validation is Linux-only. Other platform conclusions are source-reviewed, not execution claims; full hosted CI is pending. No Rust behavioral tests, implementation-name guards or README changes. This remains a draft for review.

AI-assisted implementation and validation with OpenAI Codex; model identifier unavailable. No human review is implied.

Assisted-by: OpenAI Codex:model identifier unavailable
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d2cbfc2f-4c8c-4bb0-8cb4-d59e77fae429

📥 Commits

Reviewing files that changed from the base of the PR and between b725188 and 0932821.


📒 Files selected for processing (2)
  • crates/vm/src/stdlib/posix.rs
  • extra_tests/snippets/stdlib_os.py

  • 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.

@youknowone
youknowone marked this pull request as ready for review October 10, 2026 11:09
@youknowone
youknowone enabled auto-merge (squash) October 10, 2026 11:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 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-10T11:15:31.132172Z 0932821 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 9d6bf4d into RustPython:main Oct 10, 2026
30 checks passed
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