Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: set-strategies Changeset: r49140:d6824feeab55 Date: 2011-05-01 17:15 +0200 http://bitbucket.org/pypy/pypy/changeset/d6824feeab55/
Log: added fix and tests for clear and __sub__ 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 @@ -524,12 +524,10 @@ return set_copy__Set(space, w_left) def set_clear__Set(space, w_left): - w_left.setdata.clear() + w_left.clear() def sub__Set_Set(space, w_left, w_other): - ld, rd = w_left.setdata, w_other.setdata - new_ld = _difference_dict(space, ld, rd) - return w_left._newobj(space, new_ld) + return w_left.difference(w_other) sub__Set_Frozenset = sub__Set_Set sub__Frozenset_Set = sub__Set_Set 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 @@ -68,6 +68,17 @@ a |= set([1,2,3]) assert a == b + def test_clear(self): + a = set([1,2,3]) + a.clear() + assert a == set() + + def test_sub(self): + a = set([1,2,3,4,5]) + b = set([2,3,4]) + a - b == [1,5] + a.__sub__(b) == [1,5] + def test_subtype(self): class subset(set):pass a = subset() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit