[pypy-svn] pypy bytearray: (lac, mfoord) bytearray addition with strings now works and with unicode raises the correct error
mfoord
commits-noreply at bitbucket.org
Thu Jan 20 16:54:22 CET 2011
Author: Michael Foord <michael at voidspace.org.uk>
Branch: bytearray
Changeset: r41048:48273fc83ca3
Date: 2011-01-20 16:54 +0100
http://bitbucket.org/pypy/pypy/changeset/48273fc83ca3/
Log: (lac, mfoord) bytearray addition with strings now works and with
unicode raises the correct error
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
@@ -128,6 +128,10 @@
return W_BytearrayObject(data1 + data2)
def add__Bytearray_ANY(space, w_bytearray1, w_other):
+ if space.isinstance_w(w_other, space.w_unicode):
+ raise OperationError(space.w_TypeError, space.wrap(
+ "can't concat bytearray to unicode"))
+
data1 = w_bytearray1.data
data2 = [c for c in space.bufferstr_w(w_other)]
return W_BytearrayObject(data1 + data2)
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
@@ -294,7 +294,6 @@
check(b1, "def", "abcdef")
check("def", b1, "defabc")
check(b1, memoryview("def"), "abcdef")
- check(memoryview("def"), b1, "defabc")
raises(TypeError, lambda: b1 + u"def")
raises(TypeError, lambda: u"abc" + b2)
More information about the Pypy-commit
mailing list