Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r59391:00e6e596d5ee
Date: 2012-12-10 22:00 +0100
http://bitbucket.org/pypy/pypy/changeset/00e6e596d5ee/

Log:    Implement bytes + <any-buffer>.

diff --git a/pypy/objspace/std/stringobject.py 
b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -947,6 +947,16 @@
     left = w_left._value
     return joined2(space, left, right)
 
+def add__String_ANY(space, w_left, w_right):
+    left = w_left._value
+    try:
+        right = space.buffer(w_right)
+    except OperationError, e:
+        if e.match(space, space.w_TypeError):
+            raise FailedToImplement
+        raise
+    return joined2(space, left, right.as_str())
+
 def len__String(space, w_str):
     return space.wrap(len(w_str._value))
 
diff --git a/pypy/objspace/std/test/test_stringobject.py 
b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -699,6 +699,10 @@
         assert b[1:0] == b""
         raises(TypeError, "b[3] = 'x'")
 
+    def test_concat_array(self):
+        m = memoryview(b"123")
+        assert b"abc" + m == b'abc123'
+
     def test_fromobject(self):
         class S:
             def __bytes__(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to