[pypy-svn] rev 650 - in pypy/trunk/src/pypy/objspace/std: . test

mwh at codespeak.net mwh at codespeak.net
Thu May 29 12:42:35 CEST 2003


Author: mwh
Date: Thu May 29 12:42:34 2003
New Revision: 650

Added:
   pypy/trunk/src/pypy/objspace/std/test/test_stdobjspace.py
Modified:
   pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
howl if we try to wrap an already wrapped object.  add test for this.


Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py	Thu May 29 12:42:34 2003
@@ -57,6 +57,8 @@
         "Wraps the Python value 'x' into one of the wrapper classes."
         if x is None:
             return self.w_None
+        if isinstance(x, W_Object):
+            raise TypeError, "attempt to wrap already wrapped object: %s"%(x,)
         if isinstance(x, int):
             if isinstance(x, booltype):
                 return self.newbool(x)

Added: pypy/trunk/src/pypy/objspace/std/test/test_stdobjspace.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/objspace/std/test/test_stdobjspace.py	Thu May 29 12:42:34 2003
@@ -0,0 +1,20 @@
+import testsupport
+
+from pypy.objspace.std import StdObjSpace
+
+class TestW_StdObjSpace(testsupport.TestCase):
+
+    def setUp(self):
+        self.space = StdObjSpace()
+
+    def tearDown(self):
+        pass
+
+    def test_wrap_wrap(self):
+        self.assertRaises(TypeError,
+                          self.space.wrap,
+                          self.space.wrap(0))
+
+
+if __name__ == '__main__':
+    testsupport.main()


More information about the Pypy-commit mailing list