[pypy-svn] r10363 - pypy/dist/pypy/annotation

pedronis at codespeak.net pedronis at codespeak.net
Wed Apr 6 14:24:49 CEST 2005


Author: pedronis
Date: Wed Apr  6 14:24:49 2005
New Revision: 10363

Modified:
   pypy/dist/pypy/annotation/classdef.py
   pypy/dist/pypy/annotation/unaryop.py
Log:
warning about methods that do not exist in the base class but will be demoted there, sometimes this is harmless
but it can be the wrong unwanted thing too



Modified: pypy/dist/pypy/annotation/classdef.py
==============================================================================
--- pypy/dist/pypy/annotation/classdef.py	(original)
+++ pypy/dist/pypy/annotation/classdef.py	Wed Apr  6 14:24:49 2005
@@ -180,12 +180,14 @@
                     return None
         return None
 
-    def matching(self, pbc):
+    def matching(self, pbc, name=None):
         d = {}
         uplookup = None
         upfunc = None
+        meth = False
         for func, value in pbc.prebuiltinstances.items():
             if isclassdef(value):
+                meth = True
                 if value is not self and  value.issubclass(self):
                     pass # subclasses methods are always candidates
                 elif self.issubclass(value): # upward consider only the best match
@@ -200,6 +202,10 @@
             d[func] = value
         if uplookup is not None:
             d[upfunc] = uplookup
+        elif meth:
+            if name is None:
+                name = '???'
+            self.bookkeeper.warning("demoting method %s to base class %s" % (name,self))
         if d:
             return SomePBC(d)
         else:

Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Wed Apr  6 14:24:49 2005
@@ -195,7 +195,7 @@
             #       that can't possibly apply to an instance of ins.classdef.
             # XXX do it more nicely
             if isinstance(s_result, SomePBC):
-                s_result = ins.classdef.matching(s_result)
+                s_result = ins.classdef.matching(s_result, attr)
             return s_result
         return SomeObject()
 



More information about the Pypy-commit mailing list