[pypy-svn] r18788 - in pypy/dist/pypy/rpython: . ootypesystem

arigo at codespeak.net arigo at codespeak.net
Thu Oct 20 11:55:33 CEST 2005


Author: arigo
Date: Thu Oct 20 11:55:32 2005
New Revision: 18788

Modified:
   pypy/dist/pypy/rpython/llinterp.py
   pypy/dist/pypy/rpython/ootypesystem/ootype.py
   pypy/dist/pypy/rpython/ootypesystem/rclass.py
Log:
Can't use None for abstract methods, it makes typeOf() unhappy and there is no
signature.  Use a _meth with no _callable, no graph, and abstract=True.
(thanks pedronis)



Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Thu Oct 20 11:55:32 2005
@@ -646,6 +646,8 @@
         bm = getattr(inst, message)
         m = bm.meth
         m._checkargs(args)
+        if getattr(m, 'abstract', False):
+            raise RuntimeError("calling abstract method %r" % (m,))
         return self.op_direct_call(m, inst, *args)
 
     def op_ooupcast(self, INST, inst):

Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py	Thu Oct 20 11:55:32 2005
@@ -73,11 +73,10 @@
         # _add_fields adds *descriptions* of fields.  This is obvious
         # if you are in the right state of mind (swiss?), but
         # certainly not necessarily if not.
-        # NB. a None method is a purely abstract one.
         for name, method in methods.iteritems():
             if self._has_field(name):
                 raise TypeError("Can't add method %r: field already exists" % name)
-            if method is not None and not isinstance(typeOf(method), Meth):
+            if not isinstance(typeOf(method), Meth):
                 raise TypeError("added methods must be _meths, not %s" % type(defn))
         self._methods.update(methods)
 

Modified: pypy/dist/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rclass.py	Thu Oct 20 11:55:32 2005
@@ -158,7 +158,7 @@
                         m = ootype.meth(M, _name=mangled, _callable=impl,
                                         graph=f.graph)
                     else:
-                        m = None
+                        m = ootype.meth(M, _name=mangled, abstract=True)
                     methods[mangled] = m
                     allmethods[mangled] = True
                 else:



More information about the Pypy-commit mailing list