[pypy-commit] pypy default: Test and fix.
arigo
noreply at buildbot.pypy.org
Mon Oct 29 09:36:19 CET 2012
Author: Armin Rigo <arigo at tunes.org>
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
More information about the pypy-commit
mailing list