Skip to content

Commit 126f41e

Browse files
committed
Make rustpython -i script.py work like it does in CPython
1 parent 12c57ce commit 126f41e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,15 @@ fn run_rustpython(vm: &VirtualMachine, matches: &ArgMatches) -> PyResult<()> {
368368
} else if let Some(module) = matches.value_of("m") {
369369
run_module(&vm, module)?;
370370
} else if let Some(filename) = matches.value_of("script") {
371-
run_script(&vm, scope, filename)?
371+
run_script(&vm, scope.clone(), filename)?;
372+
if matches.is_present("inspect") {
373+
shell::run_shell(&vm, scope)?;
374+
}
372375
} else {
376+
println!(
377+
"Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}",
378+
crate_version!()
379+
);
373380
shell::run_shell(&vm, scope)?;
374381
}
375382

src/shell.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ fn shell_exec(vm: &VirtualMachine, source: &str, scope: Scope) -> ShellExecResul
4141
}
4242

4343
pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
44-
println!(
45-
"Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}",
46-
crate_version!()
47-
);
48-
4944
let mut repl = Readline::new(helper::ShellHelper::new(vm, scope.clone()));
5045
let mut full_input = String::new();
5146

0 commit comments

Comments
 (0)