diff --git a/script/Cargo.toml b/script/Cargo.toml index c0e014ae..89e4af13 100644 --- a/script/Cargo.toml +++ b/script/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] thiserror = "1" -rustpython-vm = { git = "https://github.com/RustPython/RustPython.git", rev = "397392c2fd5553a6d2f714e4fdba0df43f3ced52" } +rustpython-vm = { git = "https://github.com/RustPython/RustPython.git", rev = "24800cbfcf71147392fd8579d21132780e5a9a7a", features = ["freeze-stdlib"] } serde = "1" serde_derive = "1" serde_json = "1" diff --git a/script/src/error.rs b/script/src/error.rs index 6cf42d13..8edef272 100644 --- a/script/src/error.rs +++ b/script/src/error.rs @@ -17,9 +17,8 @@ pub enum Error { impl Error { pub fn from_py(vm: &VirtualMachine, e: PyBaseExceptionRef) -> Self { - let mut buf = Vec::new(); - let _ = write_exception(&mut buf, vm, &e); - let s = String::from_utf8_lossy(&buf).into_owned(); + let mut s = String::new(); + let _ = write_exception(&mut s, vm, &e); Error::Python(s) } } diff --git a/script/src/gamedata.rs b/script/src/gamedata.rs index 8c63f32d..b814d526 100644 --- a/script/src/gamedata.rs +++ b/script/src/gamedata.rs @@ -8,8 +8,8 @@ use std::cell::RefCell; use std::convert::TryInto; use std::sync::RwLock; use vm::builtins::PyInt; -use vm::pyobject::{BorrowValue, IntoPyObject, PyObjectRef, PyResult}; use vm::VirtualMachine; +use vm::{IntoPyObject, PyObjectRef, PyResult}; thread_local!( static GAME_DATA: UnsyncLazy>> = @@ -60,7 +60,7 @@ pub fn value_to_py(vm: &VirtualMachine, value: Value) -> PyObjectRef { pub fn py_to_value(vm: &VirtualMachine, pyvalue: PyObjectRef) -> PyResult { let value = if let Some(i) = pyvalue.payload::() { - let i: i64 = i.borrow_value().try_into().unwrap(); + let i: i64 = i.as_bigint().try_into().unwrap(); Value::Int(i) } else { return Err(vm.new_type_error(format!("invalid type value \"{}\" for set_gvar", pyvalue))); diff --git a/script/src/rr.rs b/script/src/rr.rs index be6ff8c0..8e523605 100644 --- a/script/src/rr.rs +++ b/script/src/rr.rs @@ -10,8 +10,7 @@ mod _rr { use rustpython_vm as vm; use std::convert::TryInto; use vm::builtins::{PyNone, PyStrRef}; - use vm::pyobject::{PyObjectRef, PyResult, PyValue}; - use vm::VirtualMachine; + use vm::{PyObjectRef, PyResult, PyValue, VirtualMachine}; #[pyfunction] fn yield_result(vm: &VirtualMachine) -> Option {