Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions vm/src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,20 @@ pub(super) mod types {
)?;
Ok(())
}
#[pymethod(magic)]
fn reduce(exc: PyBaseExceptionRef, _vm: &VirtualMachine) -> PyTupleRef {
Comment thread
youknowone marked this conversation as resolved.
Outdated
let obj = exc.as_object().to_owned();
let mut result: Vec<PyObjectRef> = vec![
obj.class().to_owned().into(),
_vm.new_tuple((exc.get_arg(0).unwrap(),)).into(),
Comment thread
youknowone marked this conversation as resolved.
Outdated
];

if let Some(dict) = obj.dict().filter(|x| !x.is_empty()) {
result.push(dict.into());
}

result.into_pytuple(_vm)
Comment thread
youknowone marked this conversation as resolved.
Outdated
}
}

#[pyexception(name, base = "PyImportError", ctx = "module_not_found_error", impl)]
Expand Down