diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py index 33388e599..94c96a941 100644 --- a/Lib/test/test_range.py +++ b/Lib/test/test_range.py @@ -502,8 +502,6 @@ class RangeTest(unittest.TestCase): test_id = "reversed(range({}, {}, {}))".format(start, end, step) self.assert_iterators_equal(iter1, iter2, test_id, limit=100) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_range_iterators_invocation(self): # verify range iterators instances cannot be created by # calling their type diff --git a/vm/src/builtins/range.rs b/vm/src/builtins/range.rs index 3e708299e..7017f120a 100644 --- a/vm/src/builtins/range.rs +++ b/vm/src/builtins/range.rs @@ -483,6 +483,11 @@ impl PyValue for PyLongRangeIterator { #[pyimpl(with(PyIter))] impl PyLongRangeIterator { + #[pyslot] + fn tp_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { + Err(vm.new_type_error("cannot create 'longrange_iterator' instances".to_owned())) + } + #[pymethod(magic)] fn length_hint(&self) -> BigInt { let index = BigInt::from(self.index.load()); @@ -546,6 +551,11 @@ impl PyValue for PyRangeIterator { #[pyimpl(with(PyIter))] impl PyRangeIterator { + #[pyslot] + fn tp_new(_cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult { + Err(vm.new_type_error("cannot create 'range_iterator' instances".to_owned())) + } + #[pymethod(magic)] fn length_hint(&self) -> usize { let index = self.index.load();