From 556682d08cd5adf600b5f0e7f1764563140bf074 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sat, 15 Nov 2025 10:57:33 +0900 Subject: [PATCH] Fix OSError.__str__ to not display 'None' for filename --- vm/src/exceptions.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 3cf26c1d5e..a8b55ae8a4 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -1522,7 +1522,7 @@ pub(super) mod types { let msg = exc.get_arg(1).unwrap().str(vm)?; let s = match obj.get_attr("filename", vm) { - Ok(filename) => match obj.get_attr("filename2", vm) { + Ok(filename) if !vm.is_none(&filename) => match obj.get_attr("filename2", vm) { Ok(filename2) if !vm.is_none(&filename2) => format!( "[Errno {}] {}: '{}' -> '{}'", errno, @@ -1532,7 +1532,7 @@ pub(super) mod types { ), _ => format!("[Errno {}] {}: '{}'", errno, msg, filename.str(vm)?), }, - Err(_) => { + _ => { format!("[Errno {errno}] {msg}") } };