Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: 
Changeset: r62702:7491137b9517
Date: 2013-03-23 12:05 -0700
http://bitbucket.org/pypy/pypy/changeset/7491137b9517/

Log:    move hairy interface on space

diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -49,10 +49,8 @@
         return float(self.intval)
 
     def int(self, space):
-        # XXX find a better way to do it
-        if (type(self) != W_IntObject and
-            space.lookup(self, '__int__') is not
-            space.lookup_in_type_where(space.w_int, '__int__')[1]):
+        if type(self) != W_IntObject and space.is_overloaded(self, space.w_int,
+                                                             '__int__'):
             return W_Object.int(self, space)
         if space.is_w(space.type(self), space.w_int):
             return self
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -669,3 +669,8 @@
         if not hasattr(self, "_interplevel_classes"):
             return None # before running initialize
         return self._interplevel_classes.get(w_type, None)
+
+    @specialize.arg(2, 3)
+    def is_overloaded(self, w_obj, tp, method):
+        return (self.lookup(w_obj, method) is not
+                self.lookup_in_type_where(tp, method)[1])
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to