mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
@@ -1,5 +1,5 @@
|
||||
//! This module takes care of lexing python source text. This means source
|
||||
//! code is translated into seperate tokens.
|
||||
//! code is translated into separate tokens.
|
||||
|
||||
pub use super::token::Tok;
|
||||
use num_bigint::BigInt;
|
||||
|
||||
@@ -56,7 +56,7 @@ impl VirtualMachine {
|
||||
}
|
||||
}
|
||||
|
||||
// Can we get rid of the code paramter?
|
||||
// Can we get rid of the code parameter?
|
||||
|
||||
fn make_frame(&self, code: PyCodeObject, callargs: HashMap<String, Rc<NativeType>>, globals: Option<HashMap<String, Rc<NativeType>>>) -> Frame {
|
||||
//populate the globals and locals
|
||||
@@ -345,7 +345,7 @@ impl VirtualMachine {
|
||||
let exception = match argc {
|
||||
1 => curr_frame.stack.pop().unwrap(),
|
||||
0 | 2 | 3 => panic!("Not implemented!"),
|
||||
_ => panic!("Invalid paramter for RAISE_VARARGS, must be between 0 to 3")
|
||||
_ => panic!("Invalid parameter for RAISE_VARARGS, must be between 0 to 3")
|
||||
};
|
||||
panic!("{:?}", exception);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
|
||||
}
|
||||
|
||||
loop {
|
||||
// TODO: modules dont support getattr / setattr yet
|
||||
// TODO: modules don't support getattr / setattr yet
|
||||
//let prompt = match vm.get_attribute(vm.sys_module.clone(), "ps1") {
|
||||
// Ok(value) => objstr::get_value(&value),
|
||||
// Err(_) => ">>>>> ".to_string(),
|
||||
|
||||
@@ -503,7 +503,7 @@ impl Frame {
|
||||
let exception = match argc {
|
||||
1 => self.pop_value(),
|
||||
0 | 2 | 3 => panic!("Not implemented!"),
|
||||
_ => panic!("Invalid paramter for RAISE_VARARGS, must be between 0 to 3"),
|
||||
_ => panic!("Invalid parameter for RAISE_VARARGS, must be between 0 to 3"),
|
||||
};
|
||||
if objtype::isinstance(&exception, &vm.ctx.exceptions.base_exception_type) {
|
||||
info!("Exception raised: {:?}", exception);
|
||||
|
||||
@@ -58,7 +58,7 @@ pub fn to_int(
|
||||
match i32::from_str_radix(&s, base) {
|
||||
Ok(v) => v.to_bigint().unwrap(),
|
||||
Err(err) => {
|
||||
trace!("Error occured during int conversion {:?}", err);
|
||||
trace!("Error occurred during int conversion {:?}", err);
|
||||
return Err(vm.new_value_error(format!(
|
||||
"invalid literal for int() with base {}: '{}'",
|
||||
base, s
|
||||
|
||||
@@ -494,7 +494,7 @@ fn str_islower(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
))
|
||||
}
|
||||
|
||||
// doesn't implement keep new line delimeter just yet
|
||||
// doesn't implement keep new line delimiter just yet
|
||||
fn str_splitlines(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(s, Some(vm.ctx.str_type()))]);
|
||||
let elements = get_value(&s)
|
||||
|
||||
@@ -51,7 +51,7 @@ impl<'s> serde::Serialize for PyObjectSerializer<'s> {
|
||||
} else if objtype::isinstance(self.pyobject, &self.ctx.int_type()) {
|
||||
let v = objint::get_value(self.pyobject);
|
||||
serializer.serialize_i64(v.to_i64().unwrap())
|
||||
// Allthough this may seem nice, it does not give the right result:
|
||||
// Although this may seem nice, it does not give the right result:
|
||||
// v.serialize(serializer)
|
||||
} else if objtype::isinstance(self.pyobject, &self.ctx.list_type())
|
||||
|| objtype::isinstance(self.pyobject, &self.ctx.tuple_type())
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn os_close(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
let raw_fileno = objint::get_value(&fileno);
|
||||
|
||||
//The File type automatically closes when it goes out of scope.
|
||||
//To enable us to close these file desciptors (and hence prevent leaks)
|
||||
//To enable us to close these file descriptors (and hence prevent leaks)
|
||||
//we seek to create the relevant File and simply let it pass out of scope!
|
||||
rust_file(raw_fileno.to_i64().unwrap());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user