[pypy-svn] r35361 - in pypy/dist/pypy/annotation: . test

arigo at codespeak.net arigo at codespeak.net
Wed Dec 6 03:14:34 CET 2006


Author: arigo
Date: Wed Dec  6 03:13:50 2006
New Revision: 35361

Modified:
   pypy/dist/pypy/annotation/description.py
   pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
Oups!  This should have gone together with, or before, r35358.


Modified: pypy/dist/pypy/annotation/description.py
==============================================================================
--- pypy/dist/pypy/annotation/description.py	(original)
+++ pypy/dist/pypy/annotation/description.py	Wed Dec  6 03:13:50 2006
@@ -254,6 +254,10 @@
             self.specializer = policy.get_specializer(tag)
         enforceargs = getattr(self.pyobj, '_annenforceargs_', None)
         if enforceargs:
+            if not callable(enforceargs):
+                from pypy.annotation.policy import Sig
+                enforceargs = Sig(*enforceargs)
+                self.pyobj._annenforceargs_ = enforceargs
             enforceargs(self, inputcells) # can modify inputcells in-place
         return self.specializer(self, inputcells)
 

Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py	Wed Dec  6 03:13:50 2006
@@ -2363,6 +2363,18 @@
         assert not s.nonneg
         py.test.raises(Exception, a.build_types, fun, [int, int])
 
+    def test_sig_simpler(self):
+        def fun(x, y):
+            return x+y
+        s_nonneg = annmodel.SomeInteger(nonneg=True)
+        fun._annenforceargs_ = (int, s_nonneg)
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(fun, [s_nonneg, s_nonneg])
+        assert isinstance(s, annmodel.SomeInteger)
+        assert not s.nonneg
+        py.test.raises(Exception, a.build_types, fun, [int, int])
+
     def test_sig_lambda(self):
         def fun(x, y):
             return y



More information about the Pypy-commit mailing list