[pypy-commit] pypy default: Simplify the logic.
arigo
noreply at buildbot.pypy.org
Wed Oct 31 17:47:53 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r58646:fd45b4a00ced
Date: 2012-10-31 17:37 +0100
http://bitbucket.org/pypy/pypy/changeset/fd45b4a00ced/
Log: Simplify the logic.
diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -64,7 +64,7 @@
if not isinstance(self, RWBuffer):
raise OperationError(space.w_TypeError,
space.wrap("buffer is read-only"))
- start, stop, step = space.decode_index(w_index, self.getlength())
+ start, stop, step, size = space.decode_index4(w_index, self.getlength())
if step == 0: # index only
if len(newstring) != 1:
msg = 'buffer[index]=x: x must be a single character'
@@ -72,13 +72,9 @@
char = newstring[0] # annotator hint
self.setitem(start, char)
elif step == 1:
- length = stop - start
- if length != len(newstring):
- 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))
+ if len(newstring) != size:
+ 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,
More information about the pypy-commit
mailing list