Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: set-strategies Changeset: r49197:b6937fff521d Date: 2011-08-23 11:34 +0200 http://bitbucket.org/pypy/pypy/changeset/b6937fff521d/
Log: fixed recent popitem changes 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 @@ -567,12 +567,13 @@ def popitem(self, w_set): storage = self.cast_from_void_star(w_set.sstorage) try: + # this returns a tuple because internally sets are dicts result = storage.popitem() except KeyError: # strategy may still be the same even if dict is empty raise OperationError(self.space.w_KeyError, self.space.wrap('pop from an empty set')) - return self.wrap(result) + return self.wrap(result[0]) class IntegerSetStrategy(AbstractUnwrappedSetStrategy, SetStrategy): cast_to_void_star, cast_from_void_star = rerased.new_erasing_pair("integer") @@ -1044,17 +1045,7 @@ return space.wrap(hash) def set_pop__Set(space, w_left): - #XXX move this to strategy so we don't have to - # wrap all items only to get the first one - #XXX use popitem return w_left.popitem() - for w_key in w_left.getkeys(): - break - else: - raise OperationError(space.w_KeyError, - space.wrap('pop from an empty set')) - w_left.delitem(w_key) - return w_key def and__Set_Set(space, w_left, w_other): new_set = w_left.intersect(w_other) 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 @@ -640,7 +640,7 @@ assert self.FakeInt(5) in s def test_fakeobject_and_pop(self): - s = set([1,2,3,self.FakeInt(4), 5]) + s = set([1,2,3,self.FakeInt(4),5]) assert s.pop() assert s.pop() assert s.pop() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit