[pypy-svn] r27186 - in pypy/dist/pypy: annotation objspace/flow translator/c

arigo at codespeak.net arigo at codespeak.net
Sat May 13 19:16:16 CEST 2006


Author: arigo
Date: Sat May 13 19:16:14 2006
New Revision: 27186

Modified:
   pypy/dist/pypy/annotation/description.py
   pypy/dist/pypy/objspace/flow/objspace.py
   pypy/dist/pypy/translator/c/pyobj.py
Log:
Fix the test_wrapping failures.  The old behavior captured in the PyObject
wrapper strange unannotated functions and methods if they were specialized,
e.g. the ones taking *args.  Skip these now.


Modified: pypy/dist/pypy/annotation/description.py
==============================================================================
--- pypy/dist/pypy/annotation/description.py	(original)
+++ pypy/dist/pypy/annotation/description.py	Sat May 13 19:16:14 2006
@@ -158,6 +158,9 @@
     simplify_desc_set = staticmethod(simplify_desc_set)
 
 
+class NoStandardGraph(Exception):
+    """The function doesn't have a single standard non-specialized graph."""
+
 class FunctionDesc(Desc):
     knowntype = types.FunctionType
     overridden = False
@@ -192,8 +195,13 @@
         return graph
 
     def getuniquegraph(self):
-        assert len(self._cache) == 1
-        return self._cache.values()[0]
+        if len(self._cache) != 1:
+            raise NoStandardGraph(self)
+        [graph] = self._cache.values()
+        if (graph.signature != self.signature or
+            graph.defaults  != self.defaults):
+            raise NoStandardGraph(self)
+        return graph
 
     def cachedgraph(self, key, alt_name=None, builder=None):
         try:

Modified: pypy/dist/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/objspace.py	(original)
+++ pypy/dist/pypy/objspace/flow/objspace.py	Sat May 13 19:16:14 2006
@@ -256,7 +256,7 @@
         # so that it becomes even more interchangeable with the function
         # itself
         graph.signature = cpython_code_signature(code)
-        graph.defaults = func.func_defaults
+        graph.defaults = func.func_defaults or ()
         self.setup_executioncontext(ec)
         ec.build_flow()
         checkgraph(graph)

Modified: pypy/dist/pypy/translator/c/pyobj.py
==============================================================================
--- pypy/dist/pypy/translator/c/pyobj.py	(original)
+++ pypy/dist/pypy/translator/c/pyobj.py	Sat May 13 19:16:14 2006
@@ -3,6 +3,7 @@
 from types import FunctionType, CodeType, InstanceType, ClassType
 
 from pypy.objspace.flow.model import Variable, Constant, FunctionGraph
+from pypy.annotation.description import NoStandardGraph
 from pypy.translator.gensupp import builtin_base, builtin_type_base
 from pypy.translator.c.support import log
 from pypy.translator.c.wrapper import gen_wrapper, new_method_graph
@@ -215,9 +216,12 @@
         if self.shouldskipfunc(func):
             return self.skipped_function(func)
 
-        fwrapper = gen_wrapper(func, self.translator,
-                               newname=self.name_for_meth.get(func, func.__name__),
-                               as_method=func in self.is_method)
+        try:
+            fwrapper = gen_wrapper(func, self.translator,
+                                   newname=self.name_for_meth.get(func, func.__name__),
+                                   as_method=func in self.is_method)
+        except NoStandardGraph:
+            return self.skipped_function(func)
         pycfunctionobj = self.uniquename('gfunc_' + func.__name__)
         self.wrappers[pycfunctionobj] = func.__name__, self.getvalue(fwrapper), func.__doc__
         return pycfunctionobj



More information about the Pypy-commit mailing list