Skip to content

Commit 94807de

Browse files
committed
Move free functions in vm::exceptions to vm methods
1 parent 6151110 commit 94807de

File tree

12 files changed

+217
-212
lines changed

12 files changed

+217
-212
lines changed

examples/freeze/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fn run(vm: &vm::VirtualMachine) -> vm::PyResult<()> {
1313

1414
let res = vm.run_code_obj(vm.new_code_object(module), scope);
1515

16-
if let Err(err) = res {
17-
vm::exceptions::print_exception(&vm, err);
16+
if let Err(exc) = res {
17+
vm.print_exception(exc);
1818
}
1919

2020
Ok(())

examples/mini_repl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def fib(n):
7676
scope.globals.set_item("last", output, vm)?;
7777
}
7878
}
79-
Err(e) => {
80-
vm::exceptions::print_exception(vm, e);
79+
Err(exc) => {
80+
vm.print_exception(exc);
8181
}
8282
}
8383
}

src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ extern crate log;
4545

4646
use clap::{App, AppSettings, Arg, ArgMatches};
4747
use rustpython_vm::{
48-
builtins::PyInt, compile, exceptions::print_exception, match_class, scope::Scope, sysmodule,
49-
InitParameter, Interpreter, ItemProtocol, PyResult, PySettings, TypeProtocol, VirtualMachine,
48+
builtins::PyInt, compile, match_class, scope::Scope, sysmodule, InitParameter, Interpreter,
49+
ItemProtocol, PyResult, PySettings, TypeProtocol, VirtualMachine,
5050
};
5151

5252
use std::convert::TryInto;
@@ -141,8 +141,8 @@ where
141141
}
142142
}
143143
}
144-
Err(err) => {
145-
print_exception(vm, err);
144+
Err(exc) => {
145+
vm.print_exception(exc);
146146
1
147147
}
148148
};

src/shell.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustpython_parser::error::{LexicalErrorType, ParseErrorType};
44
use rustpython_vm::readline::{Readline, ReadlineResult};
55
use rustpython_vm::{
66
compile::{self, CompileError, CompileErrorType},
7-
exceptions::{print_exception, PyBaseExceptionRef},
7+
exceptions::PyBaseExceptionRef,
88
scope::Scope,
99
PyResult, TypeProtocol, VirtualMachine,
1010
};
@@ -129,7 +129,7 @@ pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
129129
repl.save_history(&repl_history_path).unwrap();
130130
return Err(exc);
131131
}
132-
print_exception(vm, exc);
132+
vm.print_exception(exc);
133133
}
134134
}
135135
repl.save_history(&repl_history_path).unwrap();

vm/src/coroutine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::builtins::{PyStrRef, PyTypeRef};
2-
use crate::exceptions::{self, PyBaseExceptionRef};
2+
use crate::exceptions::PyBaseExceptionRef;
33
use crate::frame::{ExecutionResult, FrameRef};
44
use crate::VirtualMachine;
55
use crate::{PyObjectRef, PyResult, TypeProtocol};
@@ -124,7 +124,7 @@ impl Coro {
124124
vm: &VirtualMachine,
125125
) -> PyResult {
126126
if self.closed.load() {
127-
return Err(exceptions::normalize(exc_type, exc_val, exc_tb, vm)?);
127+
return Err(vm.normalize_exception(exc_type, exc_val, exc_tb)?);
128128
}
129129
let result = self.run_with_context(vm, |f| f.gen_throw(vm, exc_type, exc_val, exc_tb));
130130
self.maybe_close(&result);

0 commit comments

Comments
 (0)