forked from Rust-related/RustPython
Allow None as with_tracebak arg
This commit is contained in:
@@ -15,3 +15,13 @@ try:
|
||||
except KeyError as ex2:
|
||||
tb = traceback.extract_tb(ex2.__traceback__)
|
||||
assert tb[1].line == "1/0"
|
||||
|
||||
|
||||
try:
|
||||
try:
|
||||
1/0
|
||||
except ZeroDivisionError as ex:
|
||||
raise ex.with_traceback(None)
|
||||
except ZeroDivisionError as ex2:
|
||||
tb = traceback.extract_tb(ex2.__traceback__)
|
||||
assert len(tb) == 1
|
||||
|
||||
@@ -210,10 +210,14 @@ fn exception_repr(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
|
||||
fn exception_with_traceback(
|
||||
zelf: PyObjectRef,
|
||||
tb: PyTracebackRef,
|
||||
tb: Option<PyTracebackRef>,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult {
|
||||
vm.set_attr(&zelf, "__traceback__", tb)?;
|
||||
vm.set_attr(
|
||||
&zelf,
|
||||
"__traceback__",
|
||||
tb.map_or(vm.get_none(), |tb| tb.into_object()),
|
||||
)?;
|
||||
Ok(zelf)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user