Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Aug 26, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Directory creation errors now always include the affected filename/path, yielding clearer, more actionable messages when mkdir operations fail.
    • Error reporting is now consistent across platforms and for both directory-file-descriptor and plain-path cases, improving diagnostics and troubleshooting.
  • Chores

    • No changes to public APIs or external behavior beyond improved error messages.

Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Introduces a dedicated C-string c_path for mkdir syscalls, preserves the original path for error reporting, replaces raw Err(errno_err(vm)) with OS-error retrieval via crate::common::os::last_os_error() and IOErrorBuilder::with_filename(&err, path, vm), and uses c_path.as_ptr() for syscalls.

Changes

Cohort / File(s) Summary
OS stdlib mkdir error handling
vm/src/stdlib/os.rs
- Create c_path from path.clone().into_cstring(vm) and use c_path.as_ptr() for mkdirat/mkdir calls
- Preserve original path (string) for error messages
- Replace Err(errno_err(vm)) with Err(IOErrorBuilder::with_filename(&err, path, vm)) everywhere
- Use crate::common::os::last_os_error() to obtain OS error before building IO error
- Apply consistently across dir_fd (mkdirat), non-dir_fd (mkdir), and Redox variants

Sequence Diagram(s)

No sequence diagram — changes are internal to error construction and syscall argument handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through paths where C-strings hide,
I clutch the original name at my side.
When mkdir stumbles, I point and say,
"Here's the file — show what went astray."
Little rabbit logs, tidy and bright. 🐇✨


📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 976f759 and f8b3a7a.

📒 Files selected for processing (1)
  • vm/src/stdlib/os.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • vm/src/stdlib/os.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
vm/src/stdlib/os.rs (3)

298-300: Rename path_str (it’s not a string) and clarify intent.

The variable holds an OsPath clone, not a string. Renaming helps avoid confusion and keeps clippy happy.

-        let path_str = path.clone(); // Clone for error reporting
+        let path_for_err = path.clone(); // Keep an OsPath clone for error reporting

303-309: Avoid let-and-return; return directly with filename-aware error.

Functionally correct, but the temporary res plus return res; is unnecessary. Returning the result of the if expression directly improves readability. Also, update the renamed variable.

-            let res = if res < 0 {
-                let err = crate::common::os::last_os_error();
-                Err(IOErrorBuilder::with_filename(&err, path_str, vm))
-            } else {
-                Ok(())
-            };
-            return res;
+            return if res < 0 {
+                let err = crate::common::os::last_os_error();
+                Err(IOErrorBuilder::with_filename(&err, path_for_err, vm))
+            } else {
+                Ok(())
+            };

314-319: Mirror the same direct-return style in the non-dir_fd/Redox path.

Same nit as above; eliminate the temporary and return immediately. Update the variable name consistently.

-        if res < 0 {
-            let err = crate::common::os::last_os_error();
-            Err(IOErrorBuilder::with_filename(&err, path_str, vm))
-        } else {
-            Ok(())
-        }
+        if res < 0 {
+            let err = crate::common::os::last_os_error();
+            return Err(IOErrorBuilder::with_filename(&err, path_for_err, vm));
+        }
+        Ok(())
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 776cabb and 976f759.

📒 Files selected for processing (1)
  • vm/src/stdlib/os.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust

Files:

  • vm/src/stdlib/os.rs
🧬 Code graph analysis (1)
vm/src/stdlib/os.rs (3)
common/src/os.rs (2)
  • last_os_error (23-34)
  • last_os_error (40-42)
vm/src/ospath.rs (1)
  • with_filename (156-167)
vm/src/stdlib/nt.rs (1)
  • mkdir (456-471)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run snippets and cpython tests on wasm-wasi

@youknowone youknowone merged commit c6d1a57 into RustPython:main Aug 26, 2025
12 checks passed
@youknowone youknowone deleted the mkdir-args branch August 26, 2025 11:46
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