Files
python-uncompyle6/test/simple_source/bug36/08_comp_gen_for.py
2019-04-22 18:42:21 -04:00

19 lines
448 B
Python

# Bug in 3.3 weakset
# Bug was not having a rule for 3.x "comp_for"
class WeakSet:
def __init__(self, data=None):
self.data = set(data)
def __iter__(self):
for item in self.data:
if item is not None:
yield item
def union(self, other):
return self.__class__(e for s in (self, other) for e in s)
a = WeakSet([1, 2, 3])
b = WeakSet([1, 3, 5])
assert list(a.union(b)) == [1, 2, 3, 5]