mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
handle panic if str is not defined in unraisablehook (#4864)
This commit is contained in:
1 parent
c9546c2419
commit
cb6cf107ba
2 files changed
+18
-1
No files matched your search
@@ -19,3 +19,13 @@ assert_raises(NameError, lambda: y) # noqa: F821
|
||||
|
||||
with assert_raises(NameError):
|
||||
del y # noqa: F821
|
||||
|
||||
# see https://github.com/RustPython/RustPython/issues/4863
|
||||
|
||||
class MyTest:
|
||||
def __del__(self):
|
||||
type(self)()
|
||||
|
||||
def test_del_panic():
|
||||
mytest = MyTest()
|
||||
del mytest
|
||||
@@ -590,7 +590,14 @@ mod sys {
|
||||
fn unraisablehook(unraisable: UnraisableHookArgs, vm: &VirtualMachine) {
|
||||
if let Err(e) = _unraisablehook(unraisable, vm) {
|
||||
let stderr = super::PyStderr(vm);
|
||||
writeln!(stderr, "{}", e.as_object().repr(vm).unwrap().as_str());
|
||||
writeln!(
|
||||
stderr,
|
||||
"{}",
|
||||
e.as_object()
|
||||
.repr(vm)
|
||||
.unwrap_or_else(|_| vm.ctx.empty_str.to_owned())
|
||||
.as_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user