[pypy-svn] r4970 - pypy/branch/src-newobjectmodel/pypy/module

mwh at codespeak.net mwh at codespeak.net
Sat Jun 5 15:32:29 CEST 2004


Author: mwh
Date: Sat Jun  5 15:32:28 2004
New Revision: 4970

Modified:
   pypy/branch/src-newobjectmodel/pypy/module/__builtin__module.py
Log:
fixes for super(), callable()


Modified: pypy/branch/src-newobjectmodel/pypy/module/__builtin__module.py
==============================================================================
--- pypy/branch/src-newobjectmodel/pypy/module/__builtin__module.py	(original)
+++ pypy/branch/src-newobjectmodel/pypy/module/__builtin__module.py	Sat Jun  5 15:32:28 2004
@@ -295,10 +295,11 @@
         return False
 
 def callable(ob):
-    # XXX remove 't is type' when we have proper types
-    #     that make this check no longer needed
-    t = type(ob)
-    return t is type or hasattr(t, '__call__')
+    for c in type(ob).__mro__:
+        if '__call__' in c.__dict__:
+            return True
+    else:
+        return False
 
 def dir(*args):
     """dir([object]) -> list of strings
@@ -561,14 +562,12 @@
         # Note: mro is an iterator, so the second loop
         # picks up where the first one left off!
         for cls in mro:
-            try:
-                # XXX
-                # XXX  build-in classes have no __dict__ currently!
-                # XXX
-                x = getattr(cls, attr)
-            except AttributeError:
+            try:                
+                x = cls.__dict__[attr]
+            except KeyError:
                 continue
-            x = _pypy_get(x, self.__self__)    # XXX replace with x.__get__
+            if hasattr(x, '__get__'):
+                x = x.__get__(self.__self__, type(self.__self__))
             return x
         raise AttributeError, attr
 



More information about the Pypy-commit mailing list