[pypy-svn] r30499 - pypy/dist/pypy/rpython

arigo at codespeak.net arigo at codespeak.net
Tue Jul 25 10:50:38 CEST 2006


Author: arigo
Date: Tue Jul 25 10:50:36 2006
New Revision: 30499

Modified:
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/rpython/rlist.py
Log:
pypy-c compatibility.


Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Tue Jul 25 10:50:36 2006
@@ -130,7 +130,7 @@
         self.lowleveltype = self.self_repr.lowleveltype
 
     def convert_const(self, obj):
-        return self.self_repr.convert_const(obj.__self__)
+        return self.self_repr.convert_const(get_builtin_method_self(obj))
 
     def rtype_simple_call(self, hop):
         # methods: look up the rtype_method_xxx()
@@ -145,10 +145,7 @@
         assert hop2.args_r[0] is self
         if isinstance(hop2.args_v[0], Constant):
             c = hop2.args_v[0].value    # get object from bound method
-            if hasattr(c, '__self__'):
-                c = c.__self__    # on top of CPython
-            else:
-                c = c.im_self     # on top of PyPy
+            c = get_builtin_method_self(c)
             hop2.args_v[0] = Constant(c)
         hop2.args_s[0] = self.s_self
         hop2.args_r[0] = self.self_repr
@@ -180,6 +177,12 @@
     hop.nb_args -= len(lst)
     return result
 
+def get_builtin_method_self(x):
+    try:
+        return x.__self__   # on top of CPython
+    except AttributeError:
+        return x.im_self    # on top of PyPy
+
 # ____________________________________________________________
 
 def rtype_builtin_bool(hop):

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Tue Jul 25 10:50:36 2006
@@ -42,7 +42,6 @@
 
     def convert_const(self, listobj):
         # get object from bound list method
-        #listobj = getattr(listobj, '__self__', listobj)
         if listobj is None:
             return self.null_const()
         if not isinstance(listobj, list):



More information about the Pypy-commit mailing list