Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r58555:e2b412fbfe09
Date: 2012-10-29 09:34 +0100
http://bitbucket.org/pypy/pypy/changeset/e2b412fbfe09/

Log:    Test and fix.

diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -74,8 +74,11 @@
         elif step == 1:
             length = stop - start
             if length != len(newstring):
-                msg = "buffer slice assignment is wrong size"
-                raise OperationError(space.w_ValueError, space.wrap(msg))
+                if length < 0 and len(newstring) == 0:
+                    pass     # ok anyway
+                else:
+                    msg = "right operand length must match slice length"
+                    raise OperationError(space.w_ValueError, space.wrap(msg))
             self.setslice(start, newstring)
         else:
             raise OperationError(space.w_ValueError,
diff --git a/pypy/module/__builtin__/test/test_buffer.py 
b/pypy/module/__builtin__/test/test_buffer.py
--- a/pypy/module/__builtin__/test/test_buffer.py
+++ b/pypy/module/__builtin__/test/test_buffer.py
@@ -117,6 +117,8 @@
         b[:] = '12345'
         assert a.tostring() == 'hello 12345'
         raises(IndexError, 'b[5] = "."')
+        b[4:2] = ''
+        assert a.tostring() == 'hello 12345'
 
         b = buffer(b, 2)
         assert len(b) == 3
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to