Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
garkimasera committed Jul 25, 2021
1 parent 2c6a68c commit 341789f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions script/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions script/src/gamedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RefCell<Option<GameData>>> =
Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn value_to_py(vm: &VirtualMachine, value: Value) -> PyObjectRef {

pub fn py_to_value(vm: &VirtualMachine, pyvalue: PyObjectRef) -> PyResult<Value> {
let value = if let Some(i) = pyvalue.payload::<PyInt>() {
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)));
Expand Down
3 changes: 1 addition & 2 deletions script/src/rr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyObjectRef> {
Expand Down

0 comments on commit 341789f

Please sign in to comment.