GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Unify nul errors by joshuamegnauth54 · Pull Request #8339 · RustPython/RustPython Conversation
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (16)
🚧 Files skipped from review as they are similar to previous changes (15)
📝 WalkthroughWalkthroughThe change introduces shared embedded-NUL error types and helpers, updates Rust error conversions, and replaces hard-coded or generic NUL-related exceptions across VM and standard-library paths. ChangesEmbedded-NUL exception standardization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I haven't realized it duplicated like that. tysm!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
crates/vm/src/stdlib/time.rs (1)
571-578: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse a helper closure to deduplicate the ASCII buffer flush logic.
The logic for flushing
asciitooutis duplicated three times. Consider extracting it into a closure to improve maintainability.♻️ Proposed refactor
let mut out = Wtf8Buf::new(); let mut ascii = String::new(); + let mut flush_ascii = |ascii: &mut String, out: &mut Wtf8Buf| -> PyResult<()> { + if !ascii.is_empty() { + let part = + host_time::strftime_ascii(ascii, &tm).map_err(|e| e.to_pyexception(vm))?; + out.extend(part.chars()); + ascii.clear(); + } + Ok(()) + }; + for codepoint in format.as_wtf8().code_points() { if codepoint.to_u32() == 0 { - if !ascii.is_empty() { - let part = - host_time::strftime_ascii(&ascii, &tm).map_err(|e| e.to_pyexception(vm))?; - out.extend(part.chars()); - ascii.clear(); - } + flush_ascii(&mut ascii, &mut out)?; out.push(codepoint); continue; } if let Some(ch) = codepoint.to_char() && ch.is_ascii() { ascii.push(ch); continue; } - if !ascii.is_empty() { - let part = - host_time::strftime_ascii(&ascii, &tm).map_err(|e| e.to_pyexception(vm))?; - out.extend(part.chars()); - ascii.clear(); - } + flush_ascii(&mut ascii, &mut out)?; out.push(codepoint); } - if !ascii.is_empty() { - let part = host_time::strftime_ascii(&ascii, &tm).map_err(|e| e.to_pyexception(vm))?; - out.extend(part.chars()); - } + flush_ascii(&mut ascii, &mut out)?; Ok(out.to_pyobject(vm))Also applies to: 589-598
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/vm/src/stdlib/time.rs` around lines 571 - 578, In the time-formatting loop, extract the repeated non-empty `ascii` buffer flush into a local helper closure that calls `host_time::strftime_ascii`, extends `out`, and clears `ascii`; replace all three duplicated flush blocks with this closure while preserving error propagation and existing output behavior.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/vm/src/stdlib/nt.rs`:
- Line 555: Update the error return in the null-character handling path to call
nul_char_error through its fully qualified exceptions module path and pass the
in-scope vm argument.
In `@crates/vm/src/stdlib/winsound.rs`:
- Line 145: Update the error return in the winsound function to reference the
exceptions module through its fully qualified path, preserving the existing
nul_char_error(vm) behavior without adding an import.
---
Nitpick comments:
In `@crates/vm/src/stdlib/time.rs`:
- Around line 571-578: In the time-formatting loop, extract the repeated
non-empty `ascii` buffer flush into a local helper closure that calls
`host_time::strftime_ascii`, extends `out`, and clears `ascii`; replace all
three duplicated flush blocks with this closure while preserving error
propagation and existing output behavior.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 9bbc6a49-f35c-4f0b-b376-cd49a5c8e422
crates/stdlib/src/grp.rscrates/stdlib/src/multiprocessing.rscrates/stdlib/src/openssl.rscrates/stdlib/src/ssl.rscrates/vm/src/buffer.rscrates/vm/src/exceptions.rscrates/vm/src/function/fspath.rscrates/vm/src/stdlib/_codecs.rscrates/vm/src/stdlib/_io.rscrates/vm/src/stdlib/nt.rscrates/vm/src/stdlib/os.rscrates/vm/src/stdlib/pwd.rscrates/vm/src/stdlib/time.rscrates/vm/src/stdlib/winsound.rscrates/vm/src/utils.rs
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
31b6e13 to
9598e8c
Compare
|
Additionally, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
07d6c70 to
d127606
Compare
|
See #8343 for info on the Ubuntu failure. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Part of RustPython#8245 to reduce the amount of work needed to review. I simplified the embedded nul errors by forwarding to the implementations in `vm::exceptions`.
d127606 to
4aa281a
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
great, looking a lot better. thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Part of #8245 to reduce the amount of work needed to review. I simplified the embedded nul errors by forwarding to the implementations in `vm::exceptions`.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.