[pypy-commit] pypy py3k: correct UNPACK_EX's counting
pjenvey
noreply at buildbot.pypy.org
Sat Apr 6 02:27:39 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63080:db0c22afb498
Date: 2013-04-05 17:25 -0700
http://bitbucket.org/pypy/pypy/changeset/db0c22afb498/
Log: correct UNPACK_EX's counting
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -604,15 +604,15 @@
w_iterable = self.popvalue()
items = self.space.fixedview(w_iterable)
itemcount = len(items)
- if right > itemcount:
- count = left + right
+ count = left + right
+ if count > itemcount:
if count == 1:
plural = ''
else:
plural = 's'
raise operationerrfmt(self.space.w_ValueError,
"need more than %d value%s to unpack",
- left + right, plural)
+ itemcount, plural)
right = itemcount - right
assert right >= 0
# push values in reverse order
diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -346,3 +346,17 @@
assert l(1, 2) == 1 + 2 + 20
assert l(1, 2, k=10) == 1 + 2 + 10
"""
+
+ def test_extended_unpacking_short(self):
+ """
+ class Seq:
+ def __getitem__(self, i):
+ if i >= 0 and i < 3: return i
+ raise IndexError
+ try:
+ a, *b, c, d, e = Seq()
+ except ValueError as e:
+ assert str(e) == "need more than 3 values to unpack"
+ else:
+ assert False, "Expected ValueError"
+ """
More information about the pypy-commit
mailing list