Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
ReadlineResult::Eof => {
break;
}
#[cfg(unix)]
ReadlineResult::OsError(num) => {
let os_error =
vm.new_exception_msg(vm.ctx.exceptions.os_error.to_owned(), format!("{num:?}"));
vm.print_exception(os_error);
break;
}
ReadlineResult::Other(err) => {
eprintln!("Readline error: {err:?}");
break;
Expand Down
4 changes: 4 additions & 0 deletions vm/src/readline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub enum ReadlineResult {
Eof,
Interrupt,
Io(std::io::Error),
#[cfg(unix)]
OsError(nix::Error),
Other(OtherError),
}

Expand Down Expand Up @@ -118,6 +120,8 @@ mod rustyline_readline {
Err(ReadlineError::Eof) => ReadlineResult::Eof,
Err(ReadlineError::Io(e)) => ReadlineResult::Io(e),
Err(ReadlineError::Signal(_)) => continue,
#[cfg(unix)]
Err(ReadlineError::Errno(num)) => ReadlineResult::OsError(num),
Err(e) => ReadlineResult::Other(e.into()),
};
}
Expand Down
2 changes: 2 additions & 0 deletions vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ mod builtins {
Err(vm.new_exception_empty(vm.ctx.exceptions.keyboard_interrupt.to_owned()))
}
ReadlineResult::Io(e) => Err(vm.new_os_error(e.to_string())),
#[cfg(unix)]
ReadlineResult::OsError(num) => Err(vm.new_os_error(num.to_string())),
ReadlineResult::Other(e) => Err(vm.new_runtime_error(e.to_string())),
}
} else {
Expand Down
Loading