[pypy-svn] r79482 - in pypy/branch/rlist-jit/pypy: annotation annotation/test rpython
arigo at codespeak.net
arigo at codespeak.net
Wed Nov 24 18:13:52 CET 2010
Author: arigo
Date: Wed Nov 24 18:13:51 2010
New Revision: 79482
Modified:
pypy/branch/rlist-jit/pypy/annotation/listdef.py
pypy/branch/rlist-jit/pypy/annotation/test/test_annrpython.py
pypy/branch/rlist-jit/pypy/rpython/rlist.py
Log:
Fixes.
Modified: pypy/branch/rlist-jit/pypy/annotation/listdef.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/annotation/listdef.py (original)
+++ pypy/branch/rlist-jit/pypy/annotation/listdef.py Wed Nov 24 18:13:51 2010
@@ -210,9 +210,10 @@
# is thus expected to live only shortly, mostly for the case
# of writing 'x.list[n]'.
self.never_resize()
- if self.listitem.mutated:
- raise ListChangeUnallowed("list already mutated")
- self.listitem.immutable = True
+ if not self.listitem.mutated:
+ self.listitem.immutable = True
+ #else: it's fine, don't set immutable=True at all (see
+ # test_can_merge_immutable_list_with_regular_list)
MOST_GENERAL_LISTDEF = ListDef(None, SomeObject())
Modified: pypy/branch/rlist-jit/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/branch/rlist-jit/pypy/annotation/test/test_annrpython.py Wed Nov 24 18:13:51 2010
@@ -3405,20 +3405,23 @@
def test_can_merge_immutable_list_with_regular_list(self):
class A:
_immutable_fields_ = 'lst[*]'
+ def foo(lst):
+ pass
+
def f(n):
a = A()
l1 = [n, 0]
l1[1] = n+1
a.lst = l1
if n > 0:
- lst = a.lst
+ foo(a.lst)
else:
- lst = []
- return lst
+ lst = [0]
+ lst[0] = n
+ foo(lst)
a = self.RPythonAnnotator()
- s = a.build_types(f, [int])
- assert not s.listdef.listitem.immutable
+ a.build_types(f, [int])
def f(n):
a = A()
@@ -3426,14 +3429,14 @@
l1[1] = n+1
a.lst = l1
if n > 0:
- lst = []
+ lst = [0]
+ lst[0] = n
+ foo(lst)
else:
- lst = a.lst
- return lst
+ foo(a.lst)
a = self.RPythonAnnotator()
- s = a.build_types(f, [int])
- assert not s.listdef.listitem.immutable
+ a.build_types(f, [int])
def g(n):
Modified: pypy/branch/rlist-jit/pypy/rpython/rlist.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/rpython/rlist.py (original)
+++ pypy/branch/rlist-jit/pypy/rpython/rlist.py Wed Nov 24 18:13:51 2010
@@ -769,7 +769,7 @@
l._ll_resize_le(newlength)
ll_delitem_nonneg.oopspec = 'list.delitem(l, index)'
-def ll_delitem(func, l, i):
+def ll_delitem(func, l, index):
if func is dum_checkidx:
length = l.ll_length()
if r_uint(index) >= r_uint(length): # see comments in ll_getitem().
@@ -781,7 +781,7 @@
if index < 0:
index += l.ll_length()
ll_assert(index >= 0, "negative list delitem index out of bound")
- ll_delitem_nonneg(dum_nocheck, l, i)
+ ll_delitem_nonneg(dum_nocheck, l, index)
# no oopspec -- the function is inlined by the JIT
def ll_extend(l1, l2):
More information about the Pypy-commit
mailing list