diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 8487a0b1d..6da9fe5ce 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -703,8 +703,6 @@ class UnionTests(unittest.TestCase): y.__args__ = [str, int] self.assertEqual(x, y) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_hash(self): self.assertEqual(hash(int | str), hash(str | int)) self.assertEqual(hash(int | str), hash(typing.Union[int, str])) diff --git a/vm/src/builtins/union.rs b/vm/src/builtins/union.rs index 461c1af37..ad1db983b 100644 --- a/vm/src/builtins/union.rs +++ b/vm/src/builtins/union.rs @@ -6,7 +6,7 @@ use crate::{ convert::ToPyObject, function::PyComparisonValue, protocol::PyMappingMethods, - types::{AsMapping, Comparable, GetAttr, Hashable, Iterable, PyComparisonOp}, + types::{AsMapping, Comparable, GetAttr, Hashable, PyComparisonOp}, AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObject, VirtualMachine, }; @@ -282,8 +282,7 @@ impl Comparable for PyUnion { impl Hashable for PyUnion { #[inline] fn hash(zelf: &crate::Py, vm: &VirtualMachine) -> PyResult { - let it = PyTuple::iter(zelf.args.clone(), vm); - let set = PyFrozenSet::from_iter(vm, it)?; + let set = PyFrozenSet::from_iter(vm, zelf.args.into_iter().cloned())?; PyFrozenSet::hash(&set.into_ref(vm), vm) } }