Skip to content

Update rustyline & socket2 #6074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2025
Merged

Conversation

ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Aug 5, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for signal-related interruptions during input, ensuring smoother user experience when signals are received.
  • Chores

    • Updated internal dependencies to newer versions for enhanced stability and compatibility. No impact on user-facing features.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2025

Walkthrough

This change updates dependency versions in Cargo.toml and stdlib/Cargo.toml, specifically for rustyline, socket2, and dns-lookup. Additionally, error handling in vm/src/readline.rs is broadened to continue on any ReadlineError::Signal(_) rather than only on WindowResized. No public interfaces are altered.

Changes

Cohort / File(s) Change Summary
Rustyline Dependency Update
Cargo.toml
Updated rustyline dependency version from "15.0.0" to "17.0.0".
Stdlib Dependency Updates
stdlib/Cargo.toml
Upgraded socket2 from "0.5.8" to "0.6.0" (with "all" features) and dns-lookup from "2" to "2.1".
Readline Error Handling
vm/src/readline.rs
Modified error handling to continue on any ReadlineError::Signal(_) instead of only WindowResized.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A hop, a skip, dependencies rise,
Rustyline’s new tricks, a pleasant surprise.
Socket2 and DNS, now shiny and new,
Readline errors broadened, the signals come through.
With every small patch, the garden grows bright—
A bunny’s delight in code done right! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
  • 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 src/utils.ts and explain its main purpose.
    • @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 comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

Documentation and Community

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

@ShaharNaveh ShaharNaveh marked this pull request as ready for review August 5, 2025 16:26
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: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91979a3 and ea97e48.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • stdlib/Cargo.toml (1 hunks)
  • vm/src/readline.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/readline.rs
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
📚 Learning: in cargo build scripts (build.rs), the environment variable cargo_cfg_target_os is guaranteed to exi...
Learnt from: arihant2math
PR: RustPython/RustPython#5790
File: build.rs:2-2
Timestamp: 2025-06-28T16:31:03.991Z
Learning: In Cargo build scripts (build.rs), the environment variable CARGO_CFG_TARGET_OS is guaranteed to exist and is automatically set by Cargo during the build process, making unwrap() safe to use when accessing this variable.

Applied to files:

  • Cargo.toml
📚 Learning: in rustpython's stat module implementation, platform-specific constants like sf_supported and sf_syn...
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.

Applied to files:

  • Cargo.toml
📚 Learning: in rustpython's stat module implementation, platform-specific constants like sf_supported and sf_syn...
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.

Applied to files:

  • Cargo.toml
📚 Learning: applies to **/*.rs : use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implement...
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust

Applied to files:

  • Cargo.toml
📚 Learning: applies to **/*.rs : follow rust best practices for error handling and memory management...
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management

Applied to files:

  • Cargo.toml
  • vm/src/readline.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). (4)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (windows-latest)
🔇 Additional comments (2)
Cargo.toml (1)

206-208: No legacy rustyline APIs detected

I searched for all known removed items from the v15→v17 bump and found no references in the workspace:

  • ReadlineError variants (WindowResized, WinResize, Utf8Error, Errno)
  • history::FileHistory
  • validate::ValidationContext

Please run cargo clippy --all-targets and perform a full test build across the workspace to ensure no other breaking changes remain.

stdlib/Cargo.toml (1)

105-109: socket2 & dns-lookup API compatibility confirmed

Our inspection of stdlib/src/socket.rs shows only stable, unchanged APIs in both crates:

  • socket2 usage is limited to:
    • Socket::new,
    • SockAddr::unix,
    • MsgHdr::new,
    • conversion via AsRawFd/AsFd (no calls to from_raw_fd or SockAddr::from_libc).
  • dns-lookup usage remains on:
    • getaddrinfo,
    • getnameinfo,
    • AddrInfoHints,
    • LookupErrorKind::System,

All of these are unchanged in socket2 0.6 and dns-lookup 2.1. No breaking‐change–related refactors are required.

Comment on lines 118 to 122
Err(ReadlineError::Eof) => ReadlineResult::Eof,
Err(ReadlineError::Io(e)) => ReadlineResult::Io(e),
Err(ReadlineError::WindowResized) => continue,
Err(ReadlineError::Signal(_)) => continue,
Err(e) => ReadlineResult::Other(e.into()),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Signal(_) swallows all signals – double-check intent

Switching from the narrow WindowResized variant to Signal(_) means the loop silently ignores every signal Rustyline forwards (e.g. SIGCONT, SIGTSTP).
If we ever want to surface some of these to Python, this will mask them.

Consider filtering only the signals we truly want to ignore (currently libc::SIGWINCH) and handle / propagate the rest:

-Err(ReadlineError::Signal(_)) => continue,
+Err(ReadlineError::Signal(sig)) if sig == libc::SIGWINCH => continue,
+Err(ReadlineError::Signal(sig)) => ReadlineResult::Other(
+    io::Error::new(io::ErrorKind::Interrupted, format!("received signal {sig}")).into()
+),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Err(ReadlineError::Eof) => ReadlineResult::Eof,
Err(ReadlineError::Io(e)) => ReadlineResult::Io(e),
Err(ReadlineError::WindowResized) => continue,
Err(ReadlineError::Signal(_)) => continue,
Err(e) => ReadlineResult::Other(e.into()),
};
Err(ReadlineError::Eof) => ReadlineResult::Eof,
Err(ReadlineError::Io(e)) => ReadlineResult::Io(e),
Err(ReadlineError::Signal(sig)) if sig == libc::SIGWINCH => continue,
Err(ReadlineError::Signal(sig)) => ReadlineResult::Other(
io::Error::new(io::ErrorKind::Interrupted, format!("received signal {sig}")).into()
),
Err(e) => ReadlineResult::Other(e.into()),
🤖 Prompt for AI Agents
In vm/src/readline.rs around lines 118 to 122, the current code matches all
signals with Err(ReadlineError::Signal(_)) and silently continues, which
swallows every signal Rustyline forwards. To fix this, change the match to
specifically check for the SIGWINCH signal (window resize) and continue only for
that, while allowing other signals to be handled or propagated appropriately.
This ensures only the intended signals are ignored and others can be surfaced to
Python if needed.

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Thank you!

@youknowone youknowone merged commit cac4948 into RustPython:main Aug 6, 2025
12 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