Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: set-strategies Changeset: r49168:d23ca90396d5 Date: 2011-05-18 18:24 +0200 http://bitbucket.org/pypy/pypy/changeset/d23ca90396d5/
Log: added test for user generated subclass of setobject 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 @@ -65,8 +65,7 @@ elif objtype is W_FrozensetObject: obj = instantiate(W_FrozensetObject) else: - itemiterator = w_self.space.iter(W_SetIterObject(newset(w_self.space))) - obj = w_self.space.call_function(w_self.space.type(w_self),itemiterator) + obj = w_self.space.call_function(w_self.space.type(w_self), None) obj.space = w_self.space obj.strategy = strategy obj.sstorage = storage @@ -81,8 +80,7 @@ elif objtype is W_FrozensetObject: obj = W_FrozensetObject(space, w_iterable) else: - itemiterator = space.iter(W_SetIterObject(w_iterable)) - obj = space.call_function(space.type(w_self), itemiterator) + obj = space.call_function(space.type(w_self), w_iterable) return obj _lifeline_ = None 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 @@ -75,6 +75,16 @@ a = set(x for x in [1,2,3]) assert a == set([1,2,3]) + def test_generator2(self): + def foo(): + for i in [1,2,3]: + yield i + class A(set): + pass + a = A([1,2,3,4,5]) + b = a.difference(foo()) + assert b == set([4,5]) + def test_or(self): a = set([0,1,2]) b = a | set([1,2,3]) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit