mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
switch RangeIndex to PyObjectRef
As `getitem` method in other types, get second argument as PyObjectRef.
This commit is contained in:
@@ -334,8 +334,8 @@ impl PyRange {
|
||||
}
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn getitem(&self, subscript: RangeIndex, vm: &VirtualMachine) -> PyResult {
|
||||
match subscript {
|
||||
fn getitem(&self, subscript: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
match RangeIndex::try_from_object(vm, subscript)? {
|
||||
RangeIndex::Slice(slice) => {
|
||||
let (mut substart, mut substop, mut substep) =
|
||||
slice.inner_indices(&self.compute_length(), vm)?;
|
||||
@@ -391,8 +391,7 @@ impl AsMapping for PyRange {
|
||||
|
||||
#[inline]
|
||||
fn subscript(zelf: PyObjectRef, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
Self::downcast_ref(&zelf, vm)
|
||||
.map(|zelf| zelf.getitem(RangeIndex::try_from_object(vm, needle)?, vm))?
|
||||
Self::downcast_ref(&zelf, vm).map(|zelf| zelf.getitem(needle, vm))?
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
Reference in New Issue
Block a user