Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,6 @@ class C:
self.assertIsNot(y, x)
self.assertIs(y.foo, y)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_deepcopy_range(self):
class I(int):
pass
Expand Down
6 changes: 0 additions & 6 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,12 @@ def test_pickle_enum(self):
test_pickle_dump_load(self.assertIs, Stooges.CURLY)
test_pickle_dump_load(self.assertIs, Stooges)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_pickle_int(self):
if isinstance(IntStooges, Exception):
raise IntStooges
test_pickle_dump_load(self.assertIs, IntStooges.CURLY)
test_pickle_dump_load(self.assertIs, IntStooges)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_pickle_float(self):
if isinstance(FloatStooges, Exception):
raise FloatStooges
Expand Down Expand Up @@ -3184,8 +3180,6 @@ def test_inspect_classify_class_attrs(self):


class MiscTestCase(unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test__all__(self):
support.check__all__(self, enum)

Expand Down
21 changes: 11 additions & 10 deletions vm/src/builtins/float.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
use num_bigint::{BigInt, ToBigInt};
use num_complex::Complex64;
use num_rational::Ratio;
use num_traits::{Signed, ToPrimitive, Zero};

use super::bytes::PyBytes;
use super::int::{self, PyInt, PyIntRef};
use super::pystr::{PyStr, PyStrRef};
use super::pytype::PyTypeRef;
use super::{int, PyBytes, PyInt, PyIntRef, PyStr, PyStrRef, PyTypeRef};
use crate::common::{float_ops, hash};
use crate::format::FormatSpec;
use crate::function::{OptionalArg, OptionalOption};
use crate::slots::{Comparable, Hashable, PyComparisonOp};
Expand All @@ -17,7 +10,10 @@ use crate::{
PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
TryFromObject, TypeProtocol,
};
use rustpython_common::{float_ops, hash};
use num_bigint::{BigInt, ToBigInt};
use num_complex::Complex64;
use num_rational::Ratio;
use num_traits::{Signed, ToPrimitive, Zero};

/// Convert a string or number to a floating point number, if possible.
#[pyclass(module = false, name = "float")]
Expand Down Expand Up @@ -490,6 +486,11 @@ impl PyFloat {
fn hex(&self) -> String {
float_ops::to_hex(self.value)
}

#[pymethod(magic)]
fn getnewargs(&self, vm: &VirtualMachine) -> PyObjectRef {
(self.value,).into_pyobject(vm)
}
}

impl Comparable for PyFloat {
Expand Down
30 changes: 14 additions & 16 deletions vm/src/builtins/int.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
use std::convert::TryFrom;
use std::fmt;
use std::mem::size_of;

use bstr::ByteSlice;
use num_bigint::{BigInt, BigUint, Sign};
use num_integer::Integer;
use num_traits::{One, Pow, PrimInt, Signed, ToPrimitive, Zero};

use super::bytearray::PyByteArray;
use super::bytes::PyBytes;
use super::float;
use super::pybool::IntoPyBool;
use super::pystr::{PyStr, PyStrRef};
use super::pytype::PyTypeRef;
use super::{float, IntoPyBool, PyByteArray, PyBytes, PyStr, PyStrRef, PyTypeRef};
use crate::common::hash;
use crate::format::FormatSpec;
use crate::function::{OptionalArg, OptionalOption};
use crate::slots::{Comparable, Hashable, PyComparisonOp};
Expand All @@ -23,7 +10,13 @@ use crate::{
PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
TryFromBorrowedObject, TypeProtocol,
};
use rustpython_common::hash;
use bstr::ByteSlice;
use num_bigint::{BigInt, BigUint, Sign};
use num_integer::Integer;
use num_traits::{One, Pow, PrimInt, Signed, ToPrimitive, Zero};
use std::convert::TryFrom;
use std::fmt;
use std::mem::size_of;

/// int(x=0) -> integer
/// int(x, base=10) -> integer
Expand Down Expand Up @@ -714,6 +707,11 @@ impl PyInt {
fn bit_count(&self) -> u32 {
self.value.iter_u32_digits().map(|n| n.count_ones()).sum()
}

#[pymethod(magic)]
fn getnewargs(&self, vm: &VirtualMachine) -> PyObjectRef {
(self.value.clone(),).into_pyobject(vm)
}
}

impl Comparable for PyInt {
Expand Down