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
1 change: 0 additions & 1 deletion Lib/test/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,6 @@ def test_takewhile(self):
self.assertEqual(list(t), [1, 1, 1])
self.assertRaises(StopIteration, next, t)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_dropwhile(self):
data = [1, 3, 5, 20, 2, 4, 6, 8]
self.assertEqual(list(dropwhile(underten, data)), [20, 2, 4, 6, 8])
Expand Down
9 changes: 4 additions & 5 deletions crates/vm/src/stdlib/itertools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod decl {
rc::PyRc,
},
convert::ToPyObject,
function::{ArgCallable, FuncArgs, OptionalArg, OptionalOption, PosArgs},
function::{FuncArgs, OptionalArg, OptionalOption, PosArgs},
protocol::{PyIter, PyIterReturn, PyNumber},
raise_if_stop,
stdlib::sys,
Expand Down Expand Up @@ -477,15 +477,15 @@ mod decl {
#[pyclass(name = "dropwhile")]
#[derive(Debug, PyPayload)]
struct PyItertoolsDropwhile {
predicate: ArgCallable,
predicate: PyObjectRef,
iterable: PyIter,
start_flag: AtomicCell<bool>,
}

#[derive(FromArgs)]
struct DropwhileNewArgs {
#[pyarg(positional)]
predicate: ArgCallable,
predicate: PyObjectRef,
#[pyarg(positional)]
iterable: PyIter,
}
Expand Down Expand Up @@ -522,8 +522,7 @@ mod decl {
if !zelf.start_flag.load() {
loop {
let obj = raise_if_stop!(iterable.next(vm)?);
let pred = predicate.clone();
let pred_value = pred.invoke((obj.clone(),), vm)?;
let pred_value = predicate.call((obj.clone(),), vm)?;
if !pred_value.try_to_bool(vm)? {
zelf.start_flag.store(true);
return Ok(PyIterReturn::Return(obj));
Expand Down
Loading