Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: 
Changeset: r73905:889096fc1bc1
Date: 2014-10-12 00:25 +0100
http://bitbucket.org/pypy/pypy/changeset/889096fc1bc1/

Log:    PyPy supports __self__ now

diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -134,7 +134,7 @@
         self.lowleveltype = self.self_repr.lowleveltype
 
     def convert_const(self, obj):
-        return self.self_repr.convert_const(get_builtin_method_self(obj))
+        return self.self_repr.convert_const(obj.__self__)
 
     def rtype_simple_call(self, hop):
         # methods: look up the rtype_method_xxx()
@@ -149,7 +149,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
-            c = get_builtin_method_self(c)
+            c = c.__self__
             hop2.args_v[0] = Constant(c)
         hop2.args_s[0] = self.s_self
         hop2.args_r[0] = self.self_repr
@@ -181,12 +181,6 @@
     del hop.args_v[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
-
 # ____________________________________________________________
 
 @typer_for(bool)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to