[pypy-commit] pypy set-strategies: fixed creating new set based on another set (needs to be copied)

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:51:10 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49199:dc7e81a7ecc4
Date: 2011-08-23 13:38 +0200
http://bitbucket.org/pypy/pypy/changeset/dc7e81a7ecc4/

Log:	fixed creating new set based on another set (needs to be copied)

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
@@ -727,8 +727,7 @@
 
     if isinstance(w_iterable, W_BaseSetObject):
         w_set.strategy = w_iterable.strategy
-        #XXX need to make copy here
-        w_set.sstorage = w_iterable.sstorage
+        w_set.sstorage = w_iterable.get_storage_copy()
         return
 
     if not isinstance(w_iterable, list):
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
@@ -669,7 +669,6 @@
         s = set([1,2,3,4])
         raises(TypeError, s.discard, [1])
 
-
     def test_discard_evil_compare(self):
         class Evil(object):
             def __init__(self, value):
@@ -685,3 +684,9 @@
         s = set([1,2, Evil(frozenset([1]))])
         raises(TypeError, s.discard, set([1]))
 
+    def test_create_set_from_set(self):
+        x = set([1,2,3])
+        y = set(x)
+        x.pop()
+        assert x == set([2,3])
+        assert y == set([1,2,3])


More information about the pypy-commit mailing list