| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughThis update modernizes string formatting throughout the codebase by adopting Rust's inline variable interpolation syntax (Rust 1.58+), replacing older positional formatting and explicit argument passing. Additionally, minor refactoring was performed to simplify assignment and control flow in a few locations, with no changes to logic, error handling, or public interfaces. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Application
participant Logger
User->>Application: Trigger action (e.g., command, REPL, error)
Application->>Logger: Log message with inline variable formatting
Logger-->>Application: Handles formatted output
Application-->>User: Continue execution or return result
Poem
📜 Recent review details Configuration used: CodeRabbit UI Reviewing files that changed from the base of the PR and between 011f194 and 5677cf8. 📒 Files selected for processing (21)
🪧 Tips ChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (.coderabbit.yaml)
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (9)src/shell.rs (1)📜 Review detailsvm/src/frame.rs (1)155-155: Consider whether logging raw REPL input is desirable
debug!("You entered {line:?}"); will emit every line the user types – including potentially sensitive data – to the log at debug level.
If the interactive shell can ever run in production or be embedded in another process that collects logs, this could leak secrets.-debug!("You entered {line:?}"); +// Debug-level logging can expose user input verbatim; enable only when really useful. +debug!(target: "repl", "You entered {line:?}");Alternatively gate the statement behind a feature flag or redact long inputs.
vm/src/stdlib/ctypes/base.rs (1)1670-1670: Debug message looks good, just watch allocation cost
debug!("Exception raised: {exception:?} …") allocates the full Debug representation of the exception even when the debug level is disabled, because log still formats the message inside the macro.
If the exception objects can be large or contain heavy .repr() implementations, you might prefer:if log::log_enabled!(log::Level::Debug) { debug!("Exception raised: {exception:?} with cause: {cause:?}"); }Purely optional; current code is acceptable for most cases.
vm/src/vm/compile.rs (1)254-254: Nit: minor wording tweak
The message now reads “Array length must be >= 0, not {n}”.
Consider adding a space after the comma for consistency with other errors:-return Err(vm.new_value_error(format!("Array length must be >= 0, not {n}"))); +return Err(vm.new_value_error(format!("array length must be >= 0, not {n}")));Also lower-case the first word to follow CPython style. Optional.
vm/src/stdlib/ctypes/function.rs (1)52-52: OK, but think about back-pressure instead of process::exit
Logging improved; however, the block still terminates the whole VM on an IO error.
For library users this is surprising. Returning an Err upward would give callers control.Out of scope for this PR, just flagging.
vm/src/builtins/object.rs (1)80-86: Consider using CString to guard against interior NULs
format!("{function}\0") is concise, but it silently accepts function names that might already contain '\0', producing an over-long C string.
Wrapping the name in CString::new() would validate this upfront and avoid undefined behaviour when the symbol is looked up.+use std::ffi::CString; ... - let terminated = format!("{function}\0"); - let pointer: Symbol<'_, FP> = unsafe { - library - .get(terminated.as_bytes()) + let terminated = CString::new(function) + .map_err(|_| vm.new_value_error("Function name contains NUL byte".to_owned()))?; + let pointer: Symbol<'_, FP> = unsafe { + library + .get(terminated.as_c_str().to_bytes_with_nul()) .map_err(|err| err.to_string()) .map_err(|err| vm.new_attribute_error(err))? };Would you like a follow-up patch covering the additional use std::ffi::CString; import and the error mapping?
stdlib/src/csv.rs (1)55-62: Minor wording polish for the new error message
"class {name} without an implementation for abstract method …" reads a little awkwardly.
Consider adding a verb for clarity:-return Err(vm.new_type_error(format!( - "class {name} without an implementation for abstract method '{methods}'" -))); +return Err(vm.new_type_error(format!( + "class {name} has no implementation for abstract method '{methods}'" +)));Same tweak applies to the plural branch below.
vm/src/exceptions.rs (1)350-351: Redundant to_string() allocation
format! already returns a String; the extra .to_string() just clones the
buffer.-return Err(vm.new_type_error( - format!("field_size_limit() takes at most 1 argument ({arg_len} given)") - .to_string(), -)); +return Err(vm.new_type_error(format!( + "field_size_limit() takes at most 1 argument ({arg_len} given)" +)));This shaves an allocation and removes a clippy inherent_to_string warning.
vm/src/builtins/complex.rs (1)208-210: Minor allocation nit: avoid an extra String
filename_suffix = format!(" ({filename})"); allocates a new String.
Because filename_suffix is only appended once, a cheaper option is:-filename_suffix = format!(" ({filename})"); +filename_suffix.push_str(" ("); +filename_suffix.push_str(filename.as_str()); +filename_suffix.push(')');Not critical, just a micro-optimisation.
65-72: Consider printing the type’s Python-level name
{ret_class} ends up using Display for Py<PyType>, which produces something like <class 'complex'>.
If you want the message to mirror CPython more closely and avoid the pointer-like wrapper you could use:-format!( - "__complex__ returned non-complex (type {ret_class}). \ +format!( + "__complex__ returned non-complex (type {}). \ The ability to return an instance of a strict subclass of complex \ is deprecated, and may be removed in a future version of Python.", - ret_class.name(), // <-- uses the type’s __name__ -) + ret_class.name(), +)Purely cosmetic; existing code compiles and behaves correctly.
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Reviewing files that changed from the base of the PR and between 4e094ea and 011f194.
📒 Files selected for processing (21)vm/src/eval.rs (1)6-6: LGTM – modernised formatting only
Inline interpolation compiles fine and is cheaper to read. No further issues spotted.
vm/src/stdlib/ctypes/structure.rs (1)56-57: Modernised formatting looks good
Inline named-parameter formatting is clearer and resolves the recent clippy::uninlined_format_args lint.
vm/src/builtins/super.rs (1)
No further issues spotted.128-130: Nice simplification – avoids std::mem::swap
Replacing the swap with direct assignment via the write guard is clearer and equally safe; lock scope remains minimal because the heavy construction happens beforehand.
stdlib/src/binascii.rs (1)758-760: Updated error string – no concerns
The inline placeholder removes the unnecessary positional argument, matching the clippy fix across the PR.
vm/src/stdlib/posix.rs (2)1992-1992: Modernize formatting with inline variable interpolation
Replacing format!("{:?}", variant) with format!("{variant:?}") here is correct and consistent with the PR’s style updates.
2188-2188: Modernize formatting with inline variable interpolation
vm/src/builtins/property.rs (1)
This change mirrors the one above for sysconf_names and correctly uses named interpolation for variant.135-136: Use inline formatting for error message
vm/src/buffer.rs (2)
Switching to "{func_args_len}" interpolation is stylistic only and aligns with the project’s formatting conventions.367-367: Use inline variable formatting in debug log
Updating to debug!("code: {code:?}") follows the new inline formatting style and has no impact on functionality.
410-410: Use inline variable formatting in debug log
vm/src/stdlib/io.rs (1)
Consistent with other debug statements, this change improves clarity without altering behavior.1163-1181: Clearer vector restoration via direct assignment – looks good
Replacing the previous buffer-swap logic with a single
vm/src/stdlib/sys.rs (1)
*v = read_buf.take(); cleanly moves the data back into the caller-supplied Vec<u8> without extra allocations or indirection.
Behavior, ownership semantics, and safety remain intact. Nice simplification.320-323: Modernised formatting looks good
The change to inline interpolation ({e}, {threshold:?}) keeps behaviour intact and silences the new clippy lint.
No functional, performance or style issues spotted here.Also applies to: 726-727
vm/src/codecs.rs (2)420-423: Redundant return successfully removed – stylistic win
Replacing return Some(Self::Utf32Be)/return None style with bare expression keeps the arm consistent with the others and is more idiomatic Rust. No functional impact noticed.
1108-1120: Uniform early-exit style in replace_errors
The last branch now ends with Err(bad_err_type(err, vm)) instead of an explicit return. This mirrors the earlier branches, trims one level of indentation, and leaves behaviour unchanged. 👍
vm/src/exceptions.rs (2)212-218: Inline-interpolation upgrade looks good
Switching to writeln!(output, " {l_text}")?; matches the new Rust 1.58-style formatting adopted in the rest of the PR. Functionality unchanged.
1613-1620: Consistent formatting in PySyntaxError::__str__
Modern interpolation ({msg}, {lineno}) improves readability with no behavioural change. Verified that the underlying variables are already PyStrRef or String, so Display is implemented.
src/lib.rs (2)200-200: Modernize debug log for command with inline variable interpolation
Clippy warnings are resolved and behavior is unchanged.
205-205: Modernize debug log for module with inline variable interpolation
Consistent with the new Rust 1.58+ formatting style and no change in functionality.
Sorry, something went wrong.
|
@coolreader18 redoxer-action is broken |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit