Skip to content

Commit f8e5ff4

Browse files
committed
fix filterfalse
1 parent 63e77a5 commit f8e5ff4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

graalpython/lib-graalpython/itertools.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class filterfalse(object):
618618

619619
@__graalpython__.builtin_method
620620
def __init__(self, func, sequence):
621-
self.func = func or (lambda x: False)
621+
self.func = func
622622
self.iterator = iter(sequence)
623623

624624
@__graalpython__.builtin_method
@@ -629,9 +629,16 @@ def __iter__(self):
629629
def __next__(self):
630630
while True:
631631
n = next(self.iterator)
632-
if not self.func(n):
632+
if self.func is None:
633+
if not n:
634+
return n
635+
elif not self.func(n):
633636
return n
634637

638+
@__graalpython__.builtin_method
639+
def __reduce__(self):
640+
return type(self), (self.func, self.iterator)
641+
635642

636643
class takewhile(object):
637644
"""Make an iterator that returns elements from the iterable as

0 commit comments

Comments
 (0)