[pypy-svn] rev 2410 - in pypy/trunk/src/pypy: interpreter interpreter/testobjspace/std

hpk at codespeak.net hpk at codespeak.net
Tue Dec 16 18:49:07 CET 2003


Author: hpk
Date: Tue Dec 16 18:49:07 2003
New Revision: 2410

Modified:
   pypy/trunk/src/pypy/interpreter/function.py
   pypy/trunk/src/pypy/interpreter/test/test_function.py
   pypy/trunk/src/pypy/objspace/std/cpythonobject.py
   pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
the dis.dis(dis.dis) goal works on both object spaces!

(samuele, holger)




Modified: pypy/trunk/src/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/function.py	(original)
+++ pypy/trunk/src/pypy/interpreter/function.py	Tue Dec 16 18:49:07 2003
@@ -189,6 +189,7 @@
         space = self.space
         def makedict(**kw):
             return kw
+        #print "APPVISI", self.code, "INTO", space.wrap(self.code)
         it = makedict(
                 func_defaults = self.defs_w and space.newtuple(self.defs_w) or space.w_None,
                 func_code = space.wrap(self.code),

Modified: pypy/trunk/src/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_function.py	(original)
+++ pypy/trunk/src/pypy/interpreter/test/test_function.py	Tue Dec 16 18:49:07 2003
@@ -17,6 +17,10 @@
         self.assertEquals(f.func_doc, None)
         self.assertEquals(f.func_name, 'f')
 
+    def test_code_is_ok(self):
+        def f(): pass
+        self.assert_(not hasattr(f.func_code, '__dict__'))
+
     def test_underunder_attributes(self):
         def f(): pass
         self.assertEquals(f.__name__, 'f')

Modified: pypy/trunk/src/pypy/objspace/std/cpythonobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/cpythonobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/cpythonobject.py	Tue Dec 16 18:49:07 2003
@@ -30,7 +30,7 @@
 
 def cpython_unwrap(space, w_obj):
     cpyobj = w_obj.cpyobj
-    if hasattr(cpyobj, '__unwrap__'):
+    if hasattr(type(cpyobj), '__unwrap__'):
         cpyobj = cpyobj.__unwrap__()
     return cpyobj
 
@@ -162,7 +162,7 @@
     if f:
         if _arity == 1:
             def cpython_f(space, w_1, f=f, pypymethod='pypy_'+_name):
-                x1 = space.unwrap(w_1)
+                x1 = w_1.cpyobj 
                 type_x1 = type(x1)
                 if hasattr(type_x1, pypymethod):
                     return getattr(type_x1, pypymethod)(x1)
@@ -173,7 +173,7 @@
                 return space.wrap(y)
         elif _arity == 2:
             def cpython_f(space, w_1, w_2, f=f, pypymethod='pypy_'+_name):
-                x1 = space.unwrap(w_1)
+                x1 = w_1.cpyobj 
                 type_x1 = type(x1)
                 if hasattr(type_x1, pypymethod):
                     return getattr(type_x1, pypymethod)(x1, w_2)
@@ -187,7 +187,7 @@
                 return space.wrap(y)
         elif _arity == 3:
             def cpython_f(space, w_1, w_2, w_3, f=f, pypymethod='pypy_'+_name):
-                x1 = space.unwrap(w_1)
+                x1 = w_1.cpyobj 
                 type_x1 = type(x1)
                 if hasattr(type_x1, pypymethod):
                     return getattr(type_x1, pypymethod)(x1, w_2, w_3)

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	Tue Dec 16 18:49:07 2003
@@ -202,7 +202,7 @@
             return listobject.W_ListObject(self, wrappeditems)
         if hasattr(type(x), '__wrap__'):
             return x.__wrap__(self)
-        # print "wrapping %r (%s)" % (x, type(x))
+        #print "wrapping %r (%s)" % (x, type(x))
         import cpythonobject
         return cpythonobject.W_CPythonObject(self, x)
 


More information about the Pypy-commit mailing list