Author: Lukas Diekmann <[email protected]>
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])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit