Fix install ujson by youknowone · Pull Request #6502 · RustPython/RustPython
Repository navigation
Fix install ujson - #6502
Merged
youknowone merged 1 commit into RustPython:main from youknowone:ssl-ujson Dec 25, 2025
Merged
Fix install ujson #6502 youknowone merged 1 commit into RustPython:main from youknowone:ssl-ujson
Conversation
youknowone
commented
Dec 25, 2025
·
edited by coderabbitai
Bot
Loading
Copy link Copy Markdown
Member
Summary by CodeRabbit
-
New Features
- Added Timeout error type for explicit socket timeout handling.
-
Bug Fixes
- Improved non-blocking socket timeout behavior and semantics.
- Enhanced connection disconnection error handling.
- Refined TLS buffer management and data processing logic.
✏️ Tip: You can customize this high-level summary in your review settings.
Fix install ujson
709ba76
coderabbitai
Bot
commented
Dec 25, 2025
·
edited
Loading
Copy link Copy Markdown
Contributor
📝 Walkthrough
WalkthroughThe changes enhance SSL read handling in non-blocking socket scenarios and timeout behavior, introducing retry logic for feeding TLS data to rustls, improved EOF/connection-closed detection, and a new Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
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. ❤️ ShareComment |
Bot
reviewed Dec 25, 2025
View reviewed changes
coderabbitai
Bot
left a comment
Copy link Copy Markdown
Contributor
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 (1)crates/stdlib/src/ssl/compat.rs (1)📜 Review details
424-466: Core fix looks correct, but consider documenting the buffer size choice.This retry logic properly handles the case where rustls reports it doesn't need more data but additional TLS records may still arrive from the network. The distinction between non-blocking (immediate return) and blocking/timeout sockets (attempt read) is correct.
Minor observations:
💡 Optional: Add explanatory comment for buffer size
- Line 439: The hardcoded
2048buffer size is reasonable for TLS records but lacks explanation. Consider adding a comment explaining why this size was chosen (e.g., typical TLS record overhead + payload).- Line 449-453: The
clone()andunwrap_or(0)are safe but slightly inefficient. The clone is necessary fortry_into_value, and the unwrap_or provides a safe fallback if conversion fails.- let data = match socket.sock_recv(2048, vm) { + // Read up to 2048 bytes (sufficient for typical TLS record: 5-byte header + up to ~16KB payload fragment) + let data = match socket.sock_recv(2048, vm) {
Configuration used : Path: .coderabbit.yml
Review profile : CHILL
Plan : Pro
📥 CommitsReviewing files that changed from the base of the PR and between ebdc033 and 709ba76 .
📒 Files selected for processing (1)crates/stdlib/src/ssl/compat.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by 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:
crates/stdlib/src/ssl/compat.rs
crates/stdlib/src/ssl.rs (2)⏰ 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). (1)crates/stdlib/src/socket.rs (4)
timeout(4165-4168)e(1115-1115)
timeout(707-709)std(1538-1538)std(1598-1598)new(2446-2450)
- GitHub Check: Run snippets and cpython tests (windows-latest)
crates/stdlib/src/ssl/compat.rs (4)youknowone merged commit
399-399: LGTM: Timeout variant appropriately distinguishes timeout errors.The new
Timeout(String)variant properly separates socket timeout scenarios from generic IO errors and WantRead conditions, improving error clarity and matching Python's timeout exception semantics.
479-481: LGTM: Simplified fallback defers to main buffer handling.The simplified
continueis appropriate here since the primary buffer-full logic is now handled inssl_read_tls_records(lines 569-585). This serves as a safety net fallback.
560-599: Excellent buffer-full handling with proper safeguards.The enhanced retry logic correctly handles rustls buffer exhaustion:
- When
read_tlsreturns 0, callsprocess_new_packetsto consume buffered data and make room- Retries once to feed remaining data
- Critical: Line 576-577 breaks if still can't consume, preventing infinite loops
The dual handling of Ok(0) and Err("buffer full") paths ensures robustness across different rustls error modes.
656-659: LGTM: Correct semantic distinction between timeout and would-block.Changing from
WantReadtoTimeoutwhen the socket times out duringselectis semantically correct.WantReadindicates a non-blocking socket would block, whileTimeoutindicates an operation exceeded its time limit. This properly aligns with Python'ssocket.timeoutexception behavior.
5122aed
into
RustPython : main
Dec 25, 2025
youknowone
deleted the
ssl-ujson
branch
December 25, 2025 01:32
coderabbitai
Bot
mentioned this pull request Dec 25, 2025 Fix SSL test_preauth_data_to_tls_server #6508 Merged coderabbitai
Bot
mentioned this pull request Jan 4, 2026 Fix SSL handshake partial send #6635 Merged coderabbitai
Bot
mentioned this pull request Mar 13, 2026 Fix SSL read over-consuming TCP data and ZeroReturn handling #7418 Merged Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment