Author: Maciej Fijalkowski <[email protected]>
Branch: virtual-arguments
Changeset: r56284:9db87467dda6
Date: 2012-07-20 10:47 +0200
http://bitbucket.org/pypy/pypy/changeset/9db87467dda6/

Log:    backout 472a414c4207

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -621,8 +621,6 @@
 class __extend__(pairtype(SomeList, SomeInteger)):
     
     def mul((lst1, int2)):
-        if not int2.nonneg:
-            raise TypeError("in [item] * times, times must be proven 
non-negative")
         return lst1.listdef.offspring()
 
     def getitem((lst1, int2)):
diff --git a/pypy/jit/codewriter/jtransform.py 
b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -1430,6 +1430,8 @@
 
     def do_fixed_newlist(self, op, args, arraydescr):
         v_length = self._get_initial_newlist_length(op, args)
+        if v_length.concretetype == lltype.Signed:
+            raise Exception("[item] * lgt must have lgt to be proven 
non-negative for the JIT")
         return SpaceOperation('new_array', [arraydescr, v_length], op.result)
 
     def do_fixed_list_len(self, op, args, arraydescr):
diff --git a/pypy/jit/codewriter/test/test_codewriter.py 
b/pypy/jit/codewriter/test/test_codewriter.py
--- a/pypy/jit/codewriter/test/test_codewriter.py
+++ b/pypy/jit/codewriter/test/test_codewriter.py
@@ -221,3 +221,14 @@
     assert 'setarrayitem_raw_i' in s
     assert 'getarrayitem_raw_i' in s
     assert 'residual_call_ir_v $<* fn _ll_1_raw_free__arrayPtr>' in s
+
+def test_newlist_negativ():
+    def f(n):
+        l = [0] * n
+        return len(l)
+
+    rtyper = support.annotate(f, [-1])
+    jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0])
+    cw = CodeWriter(FakeCPU(rtyper), [jitdriver_sd])
+    cw.find_all_graphs(FakePolicy())
+    py.test.raises(Exception, "cw.make_jitcodes(verbose=True)")
diff --git a/pypy/rpython/rlist.py b/pypy/rpython/rlist.py
--- a/pypy/rpython/rlist.py
+++ b/pypy/rpython/rlist.py
@@ -295,8 +295,6 @@
     def rtype_mul((r_lst, r_int), hop):
         cRESLIST = hop.inputconst(Void, hop.r_result.LIST)
         v_lst, v_factor = hop.inputargs(r_lst, Signed)
-        if not hop.args_s[1].nonneg:
-            raise TypeError("in [item] * times, times must be proven 
non-negative")
         return hop.gendirectcall(ll_mul, cRESLIST, v_lst, v_factor)
 
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to