[pypy-commit] pypy py3k: Fix translation
amauryfa
noreply at buildbot.pypy.org
Thu Jan 19 00:11:42 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r51470:af6e253e47d6
Date: 2012-01-18 22:09 +0100
http://bitbucket.org/pypy/pypy/changeset/af6e253e47d6/
Log: Fix translation
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -582,26 +582,34 @@
self.pushrevvalues(itemcount, items)
def UNPACK_EX(self, oparg, next_instr):
+ "a, *b, c = range(10)"
left = oparg & 0xFF
right = (oparg & 0xFF00) >> 8
w_iterable = self.popvalue()
-
items = self.space.fixedview(w_iterable)
itemcount = len(items)
-
+ if right < itemcount:
+ count = left + right
+ if count == 1:
+ plural = ''
+ else:
+ plural = 's'
+ raise operationerrfmt(self.space.w_ValueError,
+ "need more than %d value%s to unpack",
+ left + right, plural)
+ right = itemcount - right
+ assert right >= 0
+ # push values in reverse order
i = itemcount - 1
- while i >= itemcount-right:
+ while i >= right:
self.pushvalue(items[i])
i -= 1
-
- self.pushvalue(self.space.newlist(items[left:itemcount-right]))
-
+ self.pushvalue(self.space.newlist(items[left:right]))
i = left - 1
while i >= 0:
self.pushvalue(items[i])
i -= 1
-
def STORE_ATTR(self, nameindex, next_instr):
"obj.attributename = newvalue"
w_attributename = self.getname_w(nameindex)
More information about the pypy-commit
mailing list