[pypy-svn] pypy default: (mfoord) remove bytearray.__getslice__ and bytearray * 1 now returns a copy (removed incorrect shortcut)

mfoord commits-noreply at bitbucket.org
Tue Jan 18 14:39:26 CET 2011


Author: Michael Foord <michael at voidspace.org.uk>
Branch: 
Changeset: r40853:d2e1e3c8eda3
Date: 2011-01-18 14:39 +0100
http://bitbucket.org/pypy/pypy/changeset/d2e1e3c8eda3/

Log:	(mfoord) remove bytearray.__getslice__ and bytearray * 1 now returns
	a copy (removed incorrect shortcut)

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
@@ -64,11 +64,6 @@
     newdata = [data[start + i*step] for i in range(slicelength)]
     return W_BytearrayObject(newdata)
 
-def getslice__Bytearray_ANY_ANY(space, w_bytearray, w_start, w_stop):
-    length = len(w_bytearray.data)
-    start, stop = normalize_simple_slice(space, length, w_start, w_stop)
-    return W_BytearrayObject(w_bytearray.data[start:stop])
-
 def contains__Bytearray_Int(space, w_bytearray, w_char):
     char = w_char.intval
     if not 0 <= char < 256:
@@ -96,8 +91,6 @@
         if e.match(space, space.w_TypeError):
             raise FailedToImplement
         raise
-    if times == 1 and space.type(w_bytearray) == space.w_bytearray:
-        return w_bytearray
     data = w_bytearray.data
     return W_BytearrayObject(data * times)
 

diff --git a/pypy/objspace/std/test/test_bytes.py b/pypy/objspace/std/test/test_bytes.py
--- a/pypy/objspace/std/test/test_bytes.py
+++ b/pypy/objspace/std/test/test_bytes.py
@@ -57,6 +57,7 @@
         b2 = bytearray('world')
         assert b1 + b2 == bytearray('hello world')
         assert b1 * 2 == bytearray('hello hello ')
+        assert b1 * 1 is not b1
 
     def test_contains(self):
         assert ord('l') in bytearray('hello')


More information about the Pypy-commit mailing list