Skip to content

Commit 7deeb9a

Browse files
committed
Use PyResult instead of standard Result.
1 parent 86a59fe commit 7deeb9a

File tree

3 files changed

+80
-56
lines changed

3 files changed

+80
-56
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn run_file<R: io::Read, EP: sandbox::EnvProxy>(reader: &mut R, envproxy: EP
3838
let primitive_objects = objects::PrimitiveObjects::new(&mut store);
3939
let module = try!(marshal::read_object(reader, &mut store, &primitive_objects).map_err(InterpreterError::Unmarshal));
4040
let mut processor = Processor { envproxy: envproxy, store: store, primitive_functions: primitives::get_default_primitives(), primitive_objects: primitive_objects };
41-
let result = try!(processor.run_code_object(module).map_err(InterpreterError::Processor));
41+
let result = processor.run_code_object(module);
4242
Ok((processor, result))
4343
}
4444

src/primitives/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ macro_rules! parse_arguments {
3131
}};
3232
}
3333

34-
fn write_stdout<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> Result<PyResult, ProcessorError> {
34+
fn write_stdout<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> PyResult {
3535
parse_arguments!("__primitives__.write_stdout", processor.store, args,
3636
"value" "a string, boolean, or integer": {
3737
ObjectContent::String(ref s) => {
@@ -48,10 +48,10 @@ fn write_stdout<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef
4848
},
4949
}
5050
);
51-
Ok(PyResult::Return(processor.primitive_objects.none.clone()))
51+
PyResult::Return(processor.primitive_objects.none.clone())
5252
}
5353

54-
fn build_class<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> Result<PyResult, ProcessorError> {
54+
fn build_class<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> PyResult {
5555
let name;
5656
let code;
5757
let mut args_iter = args.into_iter();
@@ -72,10 +72,10 @@ fn build_class<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>
7272
else {
7373
bases
7474
};
75-
Ok(PyResult::Return(processor.store.allocate(Object::new_class(name, Some(code), processor.primitive_objects.type_.clone(), bases))))
75+
PyResult::Return(processor.store.allocate(Object::new_class(name, Some(code), processor.primitive_objects.type_.clone(), bases)))
7676
}
7777

78-
fn issubclass<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> Result<PyResult, ProcessorError> {
78+
fn issubclass<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>) -> PyResult {
7979
if args.len() != 2 {
8080
panic!(format!("__primitives__.issubclass takes 2 arguments, not {}", args.len()))
8181
}
@@ -90,7 +90,7 @@ fn issubclass<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>)
9090
continue
9191
};
9292
if candidate.is(second) {
93-
return Ok(PyResult::Return(processor.primitive_objects.true_obj.clone()))
93+
return PyResult::Return(processor.primitive_objects.true_obj.clone())
9494
};
9595
match processor.store.deref(&candidate).bases {
9696
None => (),
@@ -101,10 +101,10 @@ fn issubclass<EP: EnvProxy>(processor: &mut Processor<EP>, args: Vec<ObjectRef>)
101101
}
102102
};
103103
}
104-
Ok(PyResult::Return(processor.primitive_objects.false_obj.clone()))
104+
PyResult::Return(processor.primitive_objects.false_obj.clone())
105105
}
106106

107-
fn isinstance<EP: EnvProxy>(processor: &mut Processor<EP>, mut args: Vec<ObjectRef>) -> Result<PyResult, ProcessorError> {
107+
fn isinstance<EP: EnvProxy>(processor: &mut Processor<EP>, mut args: Vec<ObjectRef>) -> PyResult {
108108
if args.len() != 2 {
109109
panic!(format!("__primitives__.isinstance takes 2 arguments, not {}", args.len()))
110110
}

0 commit comments

Comments
 (0)