[pypy-svn] r9100 - in pypy/dist/pypy/objspace/std: . test

ac at codespeak.net ac at codespeak.net
Fri Feb 11 10:40:47 CET 2005


Author: ac
Date: Fri Feb 11 10:40:47 2005
New Revision: 9100

Added:
   pypy/dist/pypy/objspace/std/test/test_fake.py   (contents, props changed)
Modified:
   pypy/dist/pypy/objspace/std/fake.py
Log:
Make faked types a little more inheritable.

Modified: pypy/dist/pypy/objspace/std/fake.py
==============================================================================
--- pypy/dist/pypy/objspace/std/fake.py	(original)
+++ pypy/dist/pypy/objspace/std/fake.py	Fri Feb 11 10:40:47 2005
@@ -65,7 +65,9 @@
             r = cpy_type.__new__(cpy_type, *args)
         except:
             wrap_exception(space)
-        return W_Fake(space, r)
+        w_obj = space.allocate_instance(W_Fake, w_type)
+        w_obj.__init__(space, r)
+        return w_obj
 
     kw['__new__'] = gateway.interp2app(fake__new__,
                          unwrap_spec = [baseobjspace.ObjSpace,
@@ -85,6 +87,7 @@
             w_self.val = val
         def unwrap(w_self):
             return w_self.val
+                
     # cannot write to W_Fake.__name__ in Python 2.2!
     W_Fake = type(W_Object)('W_Fake%s'%(cpy_type.__name__.capitalize()),
                             (W_Object,),

Added: pypy/dist/pypy/objspace/std/test/test_fake.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/objspace/std/test/test_fake.py	Fri Feb 11 10:40:47 2005
@@ -0,0 +1,14 @@
+# test the integration of unicode and strings (even though we don't
+# really implement unicode yet).
+
+import autopath, sys
+
+
+objspacename = 'std'
+
+class AppTestFakedTypes:
+    def test_inheriting(self):
+        class MyUnicode(unicode):
+            pass
+        my_u = MyUnicode('123')
+        assert type(my_u) is MyUnicode



More information about the Pypy-commit mailing list