[pypy-svn] r57945 - in pypy/branch/tuple-nonresizable-395/pypy/annotation: . test

fijal at codespeak.net fijal at codespeak.net
Sun Sep 7 15:44:50 CEST 2008


Author: fijal
Date: Sun Sep  7 15:44:46 2008
New Revision: 57945

Modified:
   pypy/branch/tuple-nonresizable-395/pypy/annotation/listdef.py
   pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py
Log:
A logic that keeps track when merging resizable self with non-resizable
other. fragile


Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/listdef.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/listdef.py	(original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/listdef.py	Sun Sep  7 15:44:46 2008
@@ -63,8 +63,11 @@
                     # things more general
                     self, other = other, self
 
+            if self.resized and other.dont_resize:
+                raise TooLateForChange()
             if other.mutated: self.mutate()
-            if other.resized: self.resize()
+            if other.resized:
+                self.resize()
             if other.range_step != self.range_step:
                 self.setrangestep(self._step_map[type(self.range_step),
                                                  type(other.range_step)])

Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py	Sun Sep  7 15:44:46 2008
@@ -3062,6 +3062,28 @@
         py.test.raises(TooLateForChange, a.build_types, g, [])
         assert called
 
+    def test_listitem_no_mutating2(self):
+        from pypy.rlib.debug import make_sure_not_resized
+        
+        def f():
+            return make_sure_not_resized([1,2,3])
+
+        def g():
+            l = [1,2,3]
+            l.append(4)
+            return l
+
+        def fn(i):
+            if i:
+                func = f
+            else:
+                func = g
+            return func()
+
+        a = self.RPythonAnnotator()
+        py.test.raises(TooLateForChange, a.build_types, fn, [int])
+            
+
     def test_listitem_never_resize(self):
         from pypy.rlib.debug import check_annotation
 



More information about the Pypy-commit mailing list