[pypy-svn] pypy default: don't modify the result of space.listview
cfbolz
commits-noreply at bitbucket.org
Tue Mar 1 15:59:32 CET 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r42368:6429f8e51662
Date: 2011-03-01 15:59 +0100
http://bitbucket.org/pypy/pypy/changeset/6429f8e51662/
Log: don't modify the result of space.listview
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -539,9 +539,10 @@
if not space.is_w(w_by, space.w_None):
w_by = space.wrap(space.bufferstr_new_w(w_by))
w_list = space.call_method(w_str, "split", w_by, w_maxsplit)
- list_w = space.listview(w_list)
- for i in range(len(list_w)):
- list_w[i] = String2Bytearray(space, list_w[i])
+ length = space.int_w(space.len(w_list))
+ for i in range(length):
+ w_i = space.wrap(i)
+ space.setitem(w_list, w_i, String2Bytearray(space, space.getitem(w_list, w_i)))
return w_list
def str_rsplit__Bytearray_ANY_ANY(space, w_bytearray, w_by, w_maxsplit=-1):
@@ -549,9 +550,10 @@
if not space.is_w(w_by, space.w_None):
w_by = space.wrap(space.bufferstr_new_w(w_by))
w_list = space.call_method(w_str, "rsplit", w_by, w_maxsplit)
- list_w = space.listview(w_list)
- for i in range(len(list_w)):
- list_w[i] = String2Bytearray(space, list_w[i])
+ length = space.int_w(space.len(w_list))
+ for i in range(length):
+ w_i = space.wrap(i)
+ space.setitem(w_list, w_i, String2Bytearray(space, space.getitem(w_list, w_i)))
return w_list
def str_partition__Bytearray_ANY(space, w_bytearray, w_sub):
More information about the Pypy-commit
mailing list