Skip to content

Commit 556682d

Browse files
committed
Fix OSError.__str__ to not display 'None' for filename
1 parent 2071fa2 commit 556682d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vm/src/exceptions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ pub(super) mod types {
15221522
let msg = exc.get_arg(1).unwrap().str(vm)?;
15231523

15241524
let s = match obj.get_attr("filename", vm) {
1525-
Ok(filename) => match obj.get_attr("filename2", vm) {
1525+
Ok(filename) if !vm.is_none(&filename) => match obj.get_attr("filename2", vm) {
15261526
Ok(filename2) if !vm.is_none(&filename2) => format!(
15271527
"[Errno {}] {}: '{}' -> '{}'",
15281528
errno,
@@ -1532,7 +1532,7 @@ pub(super) mod types {
15321532
),
15331533
_ => format!("[Errno {}] {}: '{}'", errno, msg, filename.str(vm)?),
15341534
},
1535-
Err(_) => {
1535+
_ => {
15361536
format!("[Errno {errno}] {msg}")
15371537
}
15381538
};

0 commit comments

Comments
 (0)