Author: Ronan Lamy <[email protected]>
Branch: kill-flowobjspace
Changeset: r60825:c108ebf1f83e
Date: 2013-02-02 19:49 +0000
http://bitbucket.org/pypy/pypy/changeset/c108ebf1f83e/
Log: split FlowObjSpace.unpackiterable()
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -1019,7 +1019,7 @@
def UNPACK_SEQUENCE(self, itemcount, next_instr):
w_iterable = self.popvalue()
- items = self.space.unpackiterable(w_iterable, itemcount)
+ items = self.space.unpacksequence(w_iterable, itemcount)
self.pushrevvalues(itemcount, items)
def slice(self, w_start, w_end):
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -264,15 +264,19 @@
w_type = w_instclass
return FSException(w_type, w_value)
- def unpackiterable(self, w_iterable, expected_length=None):
- if not isinstance(w_iterable, Variable):
+ def unpackiterable(self, w_iterable):
+ if isinstance(w_iterable, Constant):
+ l = w_iterable.value
+ return [self.wrap(x) for x in l]
+ else:
+ raise UnwrapException("cannot unpack a Variable iterable ")
+
+ def unpacksequence(self, w_iterable, expected_length):
+ if isinstance(w_iterable, Constant):
l = list(self.unwrap(w_iterable))
- if expected_length is not None and len(l) != expected_length:
+ if len(l) != expected_length:
raise ValueError
return [self.wrap(x) for x in l]
- elif expected_length is None:
- raise UnwrapException("cannot unpack a Variable iterable "
- "without knowing its length")
else:
w_len = self.len(w_iterable)
w_correct = self.eq(w_len, self.wrap(expected_length))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit