[pypy-svn] r45811 - in pypy/branch/pypy-more-rtti-inprogress/annotation: . test

arigo at codespeak.net arigo at codespeak.net
Fri Aug 17 15:02:32 CEST 2007


Author: arigo
Date: Fri Aug 17 15:02:32 2007
New Revision: 45811

Modified:
   pypy/branch/pypy-more-rtti-inprogress/annotation/signature.py
   pypy/branch/pypy-more-rtti-inprogress/annotation/test/test_annrpython.py
Log:
Adapt a technique used in extfunc.py to allow list types in
_annenforceargs_.


Modified: pypy/branch/pypy-more-rtti-inprogress/annotation/signature.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/annotation/signature.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/annotation/signature.py	Fri Aug 17 15:02:32 2007
@@ -2,7 +2,8 @@
 import types
 from pypy.annotation.model import SomeBool, SomeInteger, SomeString,\
      SomeFloat, SomeList, SomeDict, s_None, SomeExternalObject,\
-     SomeObject, SomeInstance, SomeTuple, lltype_to_annotation
+     SomeObject, SomeInstance, SomeTuple, lltype_to_annotation,\
+     unionof
 from pypy.annotation.classdef import ClassDef, InstanceSource
 from pypy.annotation.listdef import ListDef, MOST_GENERAL_LISTDEF
 from pypy.annotation.dictdef import DictDef, MOST_GENERAL_DICTDEF
@@ -129,6 +130,7 @@
                                                               len(args_s),
                                                               len(inputcells)))
         for i, (s_arg, s_input) in enumerate(zip(args_s, inputcells)):
+            s_input = unionof(s_input, s_arg)
             if not s_arg.contains(s_input):
                 raise Exception("%r argument %d:\n"
                                 "expected %s,\n"

Modified: pypy/branch/pypy-more-rtti-inprogress/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/annotation/test/test_annrpython.py	Fri Aug 17 15:02:32 2007
@@ -2466,6 +2466,19 @@
         s = a.build_types(fun, [int])
         assert not s.is_constant()
 
+    def test_sig_list(self):
+        def g(buf):
+            buf.append(5)
+        g._annenforceargs_ = ([int],)
+        def fun():
+            lst = []
+            g(lst)
+            return lst[0]
+        a = self.RPythonAnnotator()
+        s = a.build_types(fun, [])
+        assert s.knowntype is int
+        assert not s.is_constant()
+
     def test_slots_check(self):
         class Base(object):
             __slots__ = 'x'



More information about the Pypy-commit mailing list