Skip to content

Commit ba8d7b5

Browse files
dannasmanyouknowone
authored andcommitted
change conditional expression
1 parent b1238ab commit ba8d7b5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

vm/src/vm/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,18 @@ impl VirtualMachine {
223223
#[cfg(feature = "encodings")]
224224
fn import_encodings(&mut self) -> PyResult<()> {
225225
self.import("encodings", None, 0).map_err(|import_err| {
226-
let err = self.new_runtime_error(
227-
"Could not import encodings. Is your RUSTPYTHONPATH set? You can also try adding your path to Setting struct's field path_list. If you don't have \
226+
let msg = if !self.state.settings.path_list.iter().any(|s| s == "PYTHONPATH" || s == "RUSTPYTHONPATH"){
227+
"Could not import encodings. Is your RUSTPYTHONPATH or PYTHONPATH set? If you don't have \
228228
access to a consistent external environment (e.g. if you're embedding \
229229
rustpython in another application), try enabling the freeze-stdlib feature"
230-
.to_owned(),
231-
);
230+
.to_owned()
231+
} else {
232+
"Could not import encodings. Try adding your path to Setting struct's path_list field. If you don't have \
233+
access to a consistent external environment (e.g. if you're embedding \
234+
rustpython in another application), try enabling the freeze-stdlib feature".to_owned()
235+
};
236+
237+
let err = self.new_runtime_error(msg);
232238
err.set_cause(Some(import_err));
233239
err
234240
})?;

0 commit comments

Comments
 (0)