@@ -102,10 +102,8 @@ fn builtin_compile(
102
102
}
103
103
} ;
104
104
105
- compile:: compile ( vm, & source, & mode, filename. value . to_string ( ) ) . map_err ( |err| {
106
- let syntax_error = vm. context ( ) . exceptions . syntax_error . clone ( ) ;
107
- vm. new_exception ( syntax_error, err. to_string ( ) )
108
- } )
105
+ compile:: compile ( vm, & source, & mode, filename. value . to_string ( ) )
106
+ . map_err ( |err| vm. new_syntax_error ( & err) )
109
107
}
110
108
111
109
fn builtin_delattr ( obj : PyObjectRef , attr : PyStringRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
@@ -151,10 +149,8 @@ fn builtin_eval(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
151
149
let source = objstr:: get_value ( source) ;
152
150
// TODO: fix this newline bug:
153
151
let source = format ! ( "{}\n " , source) ;
154
- compile:: compile ( vm, & source, & mode, "<string>" . to_string ( ) ) . map_err ( |err| {
155
- let syntax_error = vm. context ( ) . exceptions . syntax_error . clone ( ) ;
156
- vm. new_exception ( syntax_error, err. to_string ( ) )
157
- } ) ?
152
+ compile:: compile ( vm, & source, & mode, "<string>" . to_string ( ) )
153
+ . map_err ( |err| vm. new_syntax_error ( & err) ) ?
158
154
} else {
159
155
return Err ( vm. new_type_error ( "code argument must be str or code object" . to_string ( ) ) ) ;
160
156
} ;
@@ -181,10 +177,8 @@ fn builtin_exec(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
181
177
let source = objstr:: get_value ( source) ;
182
178
// TODO: fix this newline bug:
183
179
let source = format ! ( "{}\n " , source) ;
184
- compile:: compile ( vm, & source, & mode, "<string>" . to_string ( ) ) . map_err ( |err| {
185
- let syntax_error = vm. context ( ) . exceptions . syntax_error . clone ( ) ;
186
- vm. new_exception ( syntax_error, err. to_string ( ) )
187
- } ) ?
180
+ compile:: compile ( vm, & source, & mode, "<string>" . to_string ( ) )
181
+ . map_err ( |err| vm. new_syntax_error ( & err) ) ?
188
182
} else if let Ok ( code_obj) = PyCodeRef :: try_from_object ( vm, source. clone ( ) ) {
189
183
code_obj
190
184
} else {
0 commit comments