[pypy-svn] r13118 - in pypy/dist/pypy: annotation translator

pedronis at codespeak.net pedronis at codespeak.net
Mon Jun 6 18:57:55 CEST 2005


Author: pedronis
Date: Mon Jun  6 18:57:52 2005
New Revision: 13118

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/translator/annrpython.py
Log:
always normalize unbound methods to the underlying function



Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Mon Jun  6 18:57:52 2005
@@ -148,6 +148,10 @@
     def immutablevalue(self, x):
         """The most precise SomeValue instance that contains the
         immutable value x."""
+        # convert unbound methods to the underlying function
+        if hasattr(x, 'im_self') and x.im_self is None:
+            x = x.im_func
+            assert not hasattr(x, 'im_self')
         if x is sys: # special case constant sys to someobject
             return SomeObject()
         tp = type(x)
@@ -339,9 +343,7 @@
                     self.consider_pbc_call(s_init, shape, spaceop, implicit_init=init_classdef) 
 
             callable = (classdef, func)
-            if hasattr(func, 'im_func') and func.im_self is None:
-                # consider unbound methods and the undelying functions as the same
-                func = func.im_func
+            assert not hasattr(func, 'im_func') or func.im_self is not None
             self.pbc_callables.setdefault(func,{})[callable] = True
             nonnullcallables.append(callable)
 
@@ -434,10 +436,6 @@
             # don't record the access of __init__ on the classdef
             # because it is not a dynamic attribute look-up, but
             # merely a static function call
-            if hasattr(init, 'im_func'):
-                init = init.im_func
-            else:
-                assert isinstance(init, BuiltinMethodType)
             s_init = self.immutablevalue(init)
             return classdef, s_init
         else:

Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py	(original)
+++ pypy/dist/pypy/translator/annrpython.py	Mon Jun  6 18:57:52 2005
@@ -141,9 +141,8 @@
         return self.bookkeeper.pbc_maximal_access_sets
 
     def getpbccallables(self):
-        """Return mapping callable -> {(ClassDef|None, callable'): True...},
-        callable' == callable unless callable' is an unbound method then callable is callable'.im_func.
-
+        """Return mapping callable -> {(ClassDef|None, callable): True...},
+ 
         The tuples are indices in getpbcfamilies returned mapping
         """
         return self.bookkeeper.pbc_callables



More information about the Pypy-commit mailing list