[pypy-svn] r73160 - in pypy/branch/cpython-extension/pypy/objspace/std: . test

afa at codespeak.net afa at codespeak.net
Tue Mar 30 14:28:15 CEST 2010


Author: afa
Date: Tue Mar 30 14:28:13 2010
New Revision: 73160

Modified:
   pypy/branch/cpython-extension/pypy/objspace/std/objspace.py
   pypy/branch/cpython-extension/pypy/objspace/std/test/test_setobject.py
Log:
Fix space.wrap(set()), which was not tested of course...


Modified: pypy/branch/cpython-extension/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/cpython-extension/pypy/objspace/std/objspace.py	Tue Mar 30 14:28:13 2010
@@ -6,7 +6,7 @@
 from pypy.interpreter import function
 from pypy.interpreter.pyopcode import unrolling_compare_dispatch_table, \
      BytecodeCorruption
-from pypy.rlib.objectmodel import instantiate
+from pypy.rlib.objectmodel import instantiate, r_dict
 from pypy.rlib.debug import make_sure_not_resized
 from pypy.interpreter.gateway import PyPyCacheDir
 from pypy.tool.cache import Cache 
@@ -423,8 +423,11 @@
             return W_ComplexObject(x.real, x.imag)
 
         if isinstance(x, set):
-            wrappeditems = [self.wrap(item) for item in x]
-            return W_SetObject(self, wrappeditems)
+            rdict_w = r_dict(self.eq_w, self.hash_w)
+            for item in x:
+                rdict_w[self.wrap(item)] = None
+            res = W_SetObject(self, rdict_w)
+            return res
 
         if isinstance(x, frozenset):
             wrappeditems = [self.wrap(item) for item in x]

Modified: pypy/branch/cpython-extension/pypy/objspace/std/test/test_setobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/objspace/std/test/test_setobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/objspace/std/test/test_setobject.py	Tue Mar 30 14:28:13 2010
@@ -46,6 +46,8 @@
         t = W_SetObject(self.space, None)
         _initialize_set(self.space, t, self.word)
         assert self.space.eq_w(s,t)
+        u = self.space.wrap(set('simsalabim'))
+        assert self.space.eq_w(s,u)
 
 class AppTestAppSetTest:
     def test_subtype(self):



More information about the Pypy-commit mailing list