Remove several special method of complex class
According to Cpython 3.10 changes, some special methods of complex class
(`__int__`, `__float__`, etc) are removed as they always raise `TypeError`.
(reference : https://bugs.python.org/issue41974)
@@ -10,7 +10,6 @@ use crate::{
use num_complex::Complex64;
use num_traits::Zero;
use rustpython_common::{float_ops, hash};
-use std::convert::Infallible as Never;
/// Create a complex number from a real part and an optional imaginary part.
///
@@ -272,16 +271,6 @@ impl PyComplex {
self.value.conj()
}
- #[pymethod(magic)]
- fn float(&self, vm: &VirtualMachine) -> PyResult<Never> {
- Err(vm.new_type_error(String::from("Can't convert complex to float")))
- }
-
- #[pymethod(magic)]
- fn int(&self, vm: &VirtualMachine) -> PyResult<Never> {
- Err(vm.new_type_error(String::from("Can't convert complex to int")))
- }
-
#[pymethod(name = "__rmul__")]
#[pymethod(magic)]
fn mul(
@@ -310,24 +299,6 @@ impl PyComplex {
self.op(other, |a, b| inner_div(b, a, vm), vm)
}
- #[pymethod(name = "__mod__")]
- #[pymethod(name = "__rmod__")]
- fn mod_(&self, _other: PyObjectRef, vm: &VirtualMachine) -> PyResult<Never> {
- Err(vm.new_type_error("can't mod complex numbers.".to_owned()))
- }
-
- #[pymethod(name = "__rfloordiv__")]
- #[pymethod(magic)]
- fn floordiv(&self, _other: PyObjectRef, vm: &VirtualMachine) -> PyResult<Never> {
- Err(vm.new_type_error("can't take floor of complex number.".to_owned()))
- }
-
- #[pymethod(name = "__rdivmod__")]
- #[pymethod(magic)]
- fn divmod(&self, _other: PyObjectRef, vm: &VirtualMachine) -> PyResult<Never> {
- Err(vm.new_type_error("can't take floor or mod of complex number.".to_owned()))
- }
-
#[pymethod(magic)]
fn pos(&self) -> Complex64 {
self.value
