@@ -31,14 +31,14 @@ fn main() {
31
31
let settings = create_settings ( & matches) ;
32
32
let vm = VirtualMachine :: new ( settings) ;
33
33
34
- let res = run_rustpython ( & vm, matches) ;
34
+ let res = run_rustpython ( & vm, & matches) ;
35
35
// See if any exception leaked out:
36
36
handle_exception ( & vm, res) ;
37
37
38
38
#[ cfg( feature = "flame-it" ) ]
39
39
{
40
40
main_guard. end ( ) ;
41
- if let Err ( e) = write_profile ( matches) {
41
+ if let Err ( e) = write_profile ( & matches) {
42
42
error ! ( "Error writing profile information: {}" , e) ;
43
43
process:: exit ( 1 ) ;
44
44
}
@@ -146,15 +146,15 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
146
146
if matches. is_present ( "optimize" ) {
147
147
settings. optimize = matches. occurrences_of ( "optimize" ) . try_into ( ) . unwrap ( ) ;
148
148
} else if !ignore_environment {
149
- if let Some ( value) = get_env_var_value ( "PYTHONOPTIMIZE" ) {
149
+ if let Ok ( value) = get_env_var_value ( "PYTHONOPTIMIZE" ) {
150
150
settings. optimize = value;
151
151
}
152
152
}
153
153
154
154
if matches. is_present ( "verbose" ) {
155
155
settings. verbose = matches. occurrences_of ( "verbose" ) . try_into ( ) . unwrap ( ) ;
156
156
} else if !ignore_environment {
157
- if let Some ( value) = get_env_var_value ( "PYTHONVERBOSE" ) {
157
+ if let Ok ( value) = get_env_var_value ( "PYTHONVERBOSE" ) {
158
158
settings. verbose = value;
159
159
}
160
160
}
@@ -175,9 +175,9 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
175
175
}
176
176
177
177
/// Get environment variable and turn it into integer.
178
- fn get_env_var_value ( name : & str ) -> Option < u8 > {
179
- env:: var_os ( name) . map ( |value| {
180
- if let Ok ( value) = u8:: from_str ( & value. into_string ( ) . unwrap ( ) ) {
178
+ fn get_env_var_value ( name : & str ) -> Result < u8 , std :: env :: VarError > {
179
+ env:: var ( name) . map ( |value| {
180
+ if let Ok ( value) = u8:: from_str ( & value) {
181
181
value
182
182
} else {
183
183
1
@@ -201,7 +201,7 @@ fn get_paths(env_variable_name: &str) -> Vec<String> {
201
201
}
202
202
203
203
#[ cfg( feature = "flame-it" ) ]
204
- fn write_profile ( matches : ArgMatches ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
204
+ fn write_profile ( matches : & ArgMatches ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
205
205
use std:: fs:: File ;
206
206
207
207
enum ProfileFormat {
@@ -244,7 +244,7 @@ fn write_profile(matches: ArgMatches) -> Result<(), Box<dyn std::error::Error>>
244
244
Ok ( ( ) )
245
245
}
246
246
247
- fn run_rustpython ( vm : & VirtualMachine , matches : ArgMatches ) -> PyResult < ( ) > {
247
+ fn run_rustpython ( vm : & VirtualMachine , matches : & ArgMatches ) -> PyResult < ( ) > {
248
248
import:: init_importlib ( & vm, true ) ?;
249
249
250
250
if let Some ( paths) = option_env ! ( "BUILDTIME_RUSTPYTHONPATH" ) {
0 commit comments