mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add BaseException.__reduce__
This commit is contained in:
@@ -2,7 +2,8 @@ use self::types::{PyBaseException, PyBaseExceptionRef};
|
||||
use crate::common::lock::PyRwLock;
|
||||
use crate::{
|
||||
builtins::{
|
||||
traceback::PyTracebackRef, PyNone, PyStr, PyStrRef, PyTuple, PyTupleRef, PyType, PyTypeRef,
|
||||
traceback::PyTracebackRef, PyDictRef, PyNone, PyStr, PyStrRef, PyTuple, PyTupleRef, PyType,
|
||||
PyTypeRef,
|
||||
},
|
||||
class::{PyClassImpl, StaticType},
|
||||
convert::{ToPyException, ToPyObject},
|
||||
@@ -519,6 +520,18 @@ impl PyBaseException {
|
||||
let cls = zelf.class();
|
||||
format!("{}({})", cls.name(), repr_args.iter().format(", "))
|
||||
}
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn reduce(
|
||||
zelf: PyRef<Self>,
|
||||
_vm: &VirtualMachine,
|
||||
) -> (PyTypeRef, PyTupleRef, Option<PyDictRef>) {
|
||||
(
|
||||
zelf.class().clone(),
|
||||
zelf.args().clone(),
|
||||
zelf.as_object().dict(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ExceptionZoo {
|
||||
|
||||
Reference in New Issue
Block a user