Skip to content

Commit a5309a7

Browse files
committed
Rename Py{Callable, Iterable} to Arg{..}
which were not a python object but just argument helper
1 parent 7ea52cb commit a5309a7

File tree

23 files changed

+109
-105
lines changed

23 files changed

+109
-105
lines changed

src/shell/helper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustpython_vm::builtins::{PyDictRef, PyStrRef};
22
use rustpython_vm::VirtualMachine;
3-
use rustpython_vm::{PyIterable, PyResult, TryFromObject};
3+
use rustpython_vm::{ArgIterable, PyResult, TryFromObject};
44

55
pub struct ShellHelper<'vm> {
66
vm: &'vm VirtualMachine,
@@ -64,7 +64,7 @@ impl<'vm> ShellHelper<'vm> {
6464

6565
let str_iter_method = |obj, name| {
6666
let iter = self.vm.call_special_method(obj, name, ())?;
67-
PyIterable::<PyStrRef>::try_from_object(self.vm, iter)?.iter(self.vm)
67+
ArgIterable::<PyStrRef>::try_from_object(self.vm, iter)?.iter(self.vm)
6868
};
6969

7070
let (word_start, iter1, iter2) = if let Some((last, parents)) = rest.split_last() {

vm/src/builtins/bytearray.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::slots::{
2626
use crate::utils::Either;
2727
use crate::vm::VirtualMachine;
2828
use crate::{
29-
IdProtocol, IntoPyObject, PyClassDef, PyClassImpl, PyComparisonValue, PyContext, PyIterable,
29+
ArgIterable, IdProtocol, IntoPyObject, PyClassDef, PyClassImpl, PyComparisonValue, PyContext,
3030
PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
3131
};
3232
use bstr::ByteSlice;
@@ -413,7 +413,7 @@ impl PyByteArray {
413413
}
414414

415415
#[pymethod]
416-
fn join(&self, iter: PyIterable<PyBytesInner>, vm: &VirtualMachine) -> PyResult<PyByteArray> {
416+
fn join(&self, iter: ArgIterable<PyBytesInner>, vm: &VirtualMachine) -> PyResult<PyByteArray> {
417417
Ok(self.inner().join(iter, vm)?.into())
418418
}
419419

vm/src/builtins/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::slots::{
1818
use crate::utils::Either;
1919
use crate::vm::VirtualMachine;
2020
use crate::{
21-
IdProtocol, IntoPyObject, IntoPyResult, PyClassImpl, PyComparisonValue, PyContext, PyIterable,
21+
ArgIterable, IdProtocol, IntoPyObject, IntoPyResult, PyClassImpl, PyComparisonValue, PyContext,
2222
PyObjectRef, PyRef, PyResult, PyValue, TryFromBorrowedObject, TypeProtocol,
2323
};
2424
use bstr::ByteSlice;
@@ -263,7 +263,7 @@ impl PyBytes {
263263
}
264264

265265
#[pymethod]
266-
fn join(&self, iter: PyIterable<PyBytesInner>, vm: &VirtualMachine) -> PyResult<PyBytes> {
266+
fn join(&self, iter: ArgIterable<PyBytesInner>, vm: &VirtualMachine) -> PyResult<PyBytes> {
267267
Ok(self.inner.join(iter, vm)?.into())
268268
}
269269

vm/src/builtins/dict.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::iterator;
1313
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
1414
use crate::vm::{ReprGuard, VirtualMachine};
1515
use crate::{
16-
IdProtocol, IntoPyObject, ItemProtocol, PyArithmaticValue::*, PyAttributes, PyClassDef,
17-
PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef, PyRef, PyResult, PyValue,
16+
ArgIterable, IdProtocol, IntoPyObject, ItemProtocol, PyArithmaticValue::*, PyAttributes,
17+
PyClassDef, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
1818
TryFromObject, TypeProtocol,
1919
};
2020

@@ -132,7 +132,7 @@ impl PyDict {
132132
#[pyclassmethod]
133133
fn fromkeys(
134134
class: PyTypeRef,
135-
iterable: PyIterable,
135+
iterable: ArgIterable,
136136
value: OptionalArg<PyObjectRef>,
137137
vm: &VirtualMachine,
138138
) -> PyResult<PyRef<Self>> {

vm/src/builtins/iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::{int, PyInt};
99
use crate::slots::PyIter;
1010
use crate::vm::VirtualMachine;
1111
use crate::{
12-
ItemProtocol, PyCallable, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
12+
ArgCallable, ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue,
1313
TypeProtocol,
1414
};
1515

@@ -112,7 +112,7 @@ impl PyIter for PySequenceIterator {
112112
#[pyclass(module = false, name = "callable_iterator")]
113113
#[derive(Debug)]
114114
pub struct PyCallableIterator {
115-
callable: PyCallable,
115+
callable: ArgCallable,
116116
sentinel: PyObjectRef,
117117
status: AtomicCell<IterStatus>,
118118
}
@@ -125,7 +125,7 @@ impl PyValue for PyCallableIterator {
125125

126126
#[pyimpl(with(PyIter))]
127127
impl PyCallableIterator {
128-
pub fn new(callable: PyCallable, sentinel: PyObjectRef) -> Self {
128+
pub fn new(callable: ArgCallable, sentinel: PyObjectRef) -> Self {
129129
Self {
130130
callable,
131131
sentinel,

vm/src/builtins/list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhas
2424
use crate::utils::Either;
2525
use crate::vm::{ReprGuard, VirtualMachine};
2626
use crate::{
27-
PyClassDef, PyClassImpl, PyComparisonValue, PyContext, PyIterable, PyObjectRef, PyRef,
27+
ArgIterable, PyClassDef, PyClassImpl, PyComparisonValue, PyContext, PyObjectRef, PyRef,
2828
PyResult, PyValue, TryFromObject, TypeProtocol,
2929
};
3030

@@ -196,7 +196,7 @@ impl PyList {
196196
match SequenceIndex::try_from_object_for(vm, needle, Self::NAME)? {
197197
SequenceIndex::Int(index) => self.setindex(index, value, vm),
198198
SequenceIndex::Slice(slice) => {
199-
if let Ok(sec) = PyIterable::try_from_object(vm, value) {
199+
if let Ok(sec) = ArgIterable::try_from_object(vm, value) {
200200
return self.setslice(slice, sec, vm);
201201
}
202202
Err(vm.new_type_error("can only assign an iterable to a slice".to_owned()))
@@ -214,7 +214,7 @@ impl PyList {
214214
}
215215
}
216216

217-
fn setslice(&self, slice: PySliceRef, sec: PyIterable, vm: &VirtualMachine) -> PyResult<()> {
217+
fn setslice(&self, slice: PySliceRef, sec: ArgIterable, vm: &VirtualMachine) -> PyResult<()> {
218218
let items: Result<Vec<PyObjectRef>, _> = sec.iter(vm)?.collect();
219219
let items = items?;
220220
let mut elements = self.borrow_vec_mut();

vm/src/builtins/make_module.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod decl {
3434
use crate::vm::VirtualMachine;
3535
use crate::{py_io, sysmodule};
3636
use crate::{
37-
IdProtocol, ItemProtocol, PyArithmaticValue, PyCallable, PyClassImpl, PyIterable,
37+
ArgCallable, ArgIterable, IdProtocol, ItemProtocol, PyArithmaticValue, PyClassImpl,
3838
PyObjectRef, PyResult, PyValue, TryFromObject, TypeProtocol,
3939
};
4040
use num_traits::{Signed, Zero};
@@ -45,7 +45,7 @@ mod decl {
4545
}
4646

4747
#[pyfunction]
48-
fn all(iterable: PyIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResult<bool> {
48+
fn all(iterable: ArgIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResult<bool> {
4949
for item in iterable.iter(vm)? {
5050
if !item?.to_bool() {
5151
return Ok(false);
@@ -55,7 +55,7 @@ mod decl {
5555
}
5656

5757
#[pyfunction]
58-
fn any(iterable: PyIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResult<bool> {
58+
fn any(iterable: ArgIterable<IntoPyBool>, vm: &VirtualMachine) -> PyResult<bool> {
5959
for item in iterable.iter(vm)? {
6060
if item?.to_bool() {
6161
return Ok(true);
@@ -421,7 +421,7 @@ mod decl {
421421
vm: &VirtualMachine,
422422
) -> PyResult {
423423
if let OptionalArg::Present(sentinel) = sentinel {
424-
let callable = PyCallable::try_from_object(vm, iter_target)?;
424+
let callable = ArgCallable::try_from_object(vm, iter_target)?;
425425
Ok(PyCallableIterator::new(callable, sentinel)
426426
.into_ref(vm)
427427
.into_object())
@@ -755,7 +755,7 @@ mod decl {
755755
#[derive(FromArgs)]
756756
pub struct SumArgs {
757757
#[pyarg(positional)]
758-
iterable: PyIterable,
758+
iterable: ArgIterable,
759759
#[pyarg(any, optional)]
760760
start: OptionalArg<PyObjectRef>,
761761
}

vm/src/builtins/pystr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, SlotC
1515
use crate::utils::Either;
1616
use crate::VirtualMachine;
1717
use crate::{
18-
IdProtocol, IntoPyObject, ItemProtocol, PyClassDef, PyClassImpl, PyComparisonValue, PyContext,
19-
PyIterable, PyObjectRef, PyRef, PyResult, PyValue, TryIntoRef, TypeProtocol,
18+
ArgIterable, IdProtocol, IntoPyObject, ItemProtocol, PyClassDef, PyClassImpl,
19+
PyComparisonValue, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryIntoRef, TypeProtocol,
2020
};
2121
use bstr::ByteSlice;
2222
use crossbeam_utils::atomic::AtomicCell;
@@ -937,7 +937,7 @@ impl PyStr {
937937
}
938938

939939
#[pymethod]
940-
fn join(&self, iterable: PyIterable<PyStrRef>, vm: &VirtualMachine) -> PyResult<String> {
940+
fn join(&self, iterable: ArgIterable<PyStrRef>, vm: &VirtualMachine) -> PyResult<String> {
941941
let iter = iterable.iter(vm)?;
942942
self.as_str().py_join(iter)
943943
}

0 commit comments

Comments
 (0)