Author: Lukas Diekmann <[email protected]>
Branch: set-strategies
Changeset: r49156:64ffc4b0905b
Date: 2011-05-13 15:51 +0200
http://bitbucket.org/pypy/pypy/changeset/64ffc4b0905b/
Log: fixed EmptySetStrategy.issuperset
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -261,7 +261,9 @@
return True
def issuperset(self, w_set, w_other):
- if self.space.unwrap(self.space.len(w_other)) == 0:
+ if isinstance(w_other, W_BaseSetObject) and w_other.strategy is
EmptySetStrategy:
+ return True
+ elif len(self.space.unpackiterable(w_other)) == 0:
return True
return False
diff --git a/pypy/objspace/std/test/test_setobject.py
b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -509,12 +509,16 @@
assert e.issuperset(x) == False
assert x.issuperset(e) == True
+ assert e.issuperset(set())
+ assert e.issuperset([])
+
def test_empty_issubset(self):
e = set()
x = set([1,2,3])
assert e.issubset(e) == True
assert e.issubset(x) == True
assert x.issubset(e) == False
+ assert e.issubset([])
def test_empty_isdisjoint(self):
e = set()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit