[pypy-svn] r31645 - in pypy/dist/pypy/rpython: . test

fijal at codespeak.net fijal at codespeak.net
Fri Aug 25 17:07:16 CEST 2006


Author: fijal
Date: Fri Aug 25 17:07:13 2006
New Revision: 31645

Modified:
   pypy/dist/pypy/rpython/nonconst.py
   pypy/dist/pypy/rpython/test/test_nonconst.py
Log:
Fixed non-const list, but I'm not sure if it works.


Modified: pypy/dist/pypy/rpython/nonconst.py
==============================================================================
--- pypy/dist/pypy/rpython/nonconst.py	(original)
+++ pypy/dist/pypy/rpython/nonconst.py	Fri Aug 25 17:07:13 2006
@@ -14,7 +14,10 @@
     _about_ = NonConstant
     
     def compute_result_annotation(self, arg):
-        return getbookkeeper().annotation_from_example(arg.const)
+        if hasattr(arg, 'const'):
+            return getbookkeeper().annotation_from_example(arg.const)
+        else:
+            return arg
 
     def specialize_call(self, hop):
         v = Variable()

Modified: pypy/dist/pypy/rpython/test/test_nonconst.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_nonconst.py	(original)
+++ pypy/dist/pypy/rpython/test/test_nonconst.py	Fri Aug 25 17:07:13 2006
@@ -16,3 +16,13 @@
     s = a.build_types(nonconst_f, [])
     assert s.knowntype is int
     assert not hasattr(s, 'const')
+
+def test_nonconst_list():
+    def nonconst_l():
+        a = NonConstant([1, 2, 3])
+        return a[0]
+    
+    a = RPythonAnnotator()
+    s = a.build_types(nonconst_l, [])
+    assert s.knowntype is int
+    assert not hasattr(s, 'const')



More information about the Pypy-commit mailing list