mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add __reduce__ method to Ellipsis
This commit is contained in:
@@ -11,6 +11,9 @@ assert b is c
|
||||
assert b is d
|
||||
assert d is e
|
||||
|
||||
assert Ellipsis.__repr__() == 'Ellipsis'
|
||||
assert Ellipsis.__reduce__() == 'Ellipsis'
|
||||
|
||||
assert Ellipsis is ...
|
||||
Ellipsis = 2
|
||||
assert Ellipsis is not ...
|
||||
|
||||
@@ -5,7 +5,8 @@ use crate::vm::VirtualMachine;
|
||||
pub fn init(context: &PyContext) {
|
||||
extend_class!(context, &context.ellipsis_type, {
|
||||
"__new__" => context.new_rustfunc(ellipsis_new),
|
||||
"__repr__" => context.new_rustfunc(ellipsis_repr)
|
||||
"__repr__" => context.new_rustfunc(ellipsis_repr),
|
||||
"__reduce__" => context.new_rustfunc(ellipsis_reduce),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,3 +19,8 @@ fn ellipsis_repr(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(_cls, None)]);
|
||||
Ok(vm.new_str("Ellipsis".to_string()))
|
||||
}
|
||||
|
||||
fn ellipsis_reduce(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(_cls, None)]);
|
||||
Ok(vm.new_str("Ellipsis".to_string()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user