Skip to content

Commit c8cc54f

Browse files
authored
Fix resource index conversion and REPL warning (#8654)
Accept __index__ values when converting resource limits and only report PyREPL fallback reasons for terminal-backed interactive sessions. Assisted-by: Codex:gpt-5
1 parent a8aa383 commit c8cc54f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎crates/stdlib/src/resource.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ mod resource {
175175
}
176176

177177
fn py2rlim_limit(obj: &PyObject, vm: &VirtualMachine) -> PyResult<host_resource::rlim_t> {
178-
let int = obj.try_to_ref::<crate::vm::builtins::PyInt>(vm)?;
178+
let int = obj.try_index(vm)?;
179179
if int.as_bigint().is_negative() {
180180
return Err(vm.new_value_error("Cannot convert negative int"));
181181
}

‎src/lib.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> {
361361
RunMode::Repl => Ok(()),
362362
};
363363
let result = if is_repl || vm.state.config.settings.inspect {
364-
warn_if_pyrepl_unavailable(vm);
364+
if std::io::stdin().is_terminal() {
365+
warn_if_pyrepl_unavailable(vm);
366+
}
365367
shell::run_shell(vm, scope)
366368
} else {
367369
res

0 commit comments

Comments
 (0)