[pypy-svn] r55194 - in pypy/dist/pypy/translator: . test

afa at codespeak.net afa at codespeak.net
Sat May 24 22:25:57 CEST 2008


Author: afa
Date: Sat May 24 22:25:56 2008
New Revision: 55194

Modified:
   pypy/dist/pypy/translator/geninterplevel.py
   pypy/dist/pypy/translator/test/snippet.py
Log:
Classmethods crash the geninterp transformer.
Skip them, until someone really need them.


Modified: pypy/dist/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/dist/pypy/translator/geninterplevel.py	(original)
+++ pypy/dist/pypy/translator/geninterplevel.py	Sat May 24 22:25:56 2008
@@ -51,7 +51,7 @@
 from pypy.objspace.flow.model import Variable, Constant, SpaceOperation
 from pypy.objspace.flow.model import c_last_exception, checkgraph
 from pypy.interpreter.pycode import CO_VARARGS, CO_VARKEYWORDS
-from types import FunctionType, CodeType, ModuleType
+from types import FunctionType, CodeType, ModuleType, MethodType
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.argument import Arguments
 from pypy.translator.backendopt.ssa import SSI_to_SSA
@@ -802,6 +802,9 @@
 ##                 if isinstance(value, FunctionType) and value not in self.translator.flowgraphs and self.translator.frozen:
 ##                     log.WARNING("skipped function: %s" % value)
 ##                     continue
+                if isinstance(value, MethodType) and value.im_self is cls:
+                    log.WARNING("skipped classmethod: %s" % value)
+                    continue
                     
                 yield 'space.setattr(%s, %s, %s)' % (
                     name, self.nameof(key), self.nameof(value))

Modified: pypy/dist/pypy/translator/test/snippet.py
==============================================================================
--- pypy/dist/pypy/translator/test/snippet.py	(original)
+++ pypy/dist/pypy/translator/test/snippet.py	Sat May 24 22:25:56 2008
@@ -473,6 +473,15 @@
     call_Z_my_method(global_z)
     call_Z_my_method(z)
 
+class ClassWithMethods:
+    def cm(cls, x):
+        return x
+    cm = classmethod(cm)
+
+    def sm(x):
+        return x
+    sm = staticmethod(sm)
+
 
 global_c = C()
 global_c.a = 1



More information about the Pypy-commit mailing list