[pypy-svn] r7344 - pypy/trunk/src/pypy/objspace/flow
arigo at codespeak.net
arigo at codespeak.net
Wed Nov 17 17:57:48 CET 2004
Author: arigo
Date: Wed Nov 17 17:57:48 2004
New Revision: 7344
Modified:
pypy/trunk/src/pypy/objspace/flow/objspace.py
Log:
unpackiterable() on the flow object space cannot succeed, so let's
HACK: pretend the iterable cannot have more than 7 items, and forget about the
consequences.
Modified: pypy/trunk/src/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/flow/objspace.py Wed Nov 17 17:57:48 2004
@@ -141,8 +141,19 @@
def unpackiterable(self, w_iterable, expected_length=None):
if isinstance(w_iterable, Variable) and expected_length is None:
- raise UnwrapException, ("cannot unpack a Variable iterable "
- "without knowing its length")
+ print ("*** cannot unpack a Variable iterable "
+ "without knowing its length, assuming up to 7 items")
+ w_iterator = self.iter(w_iterable)
+ items = []
+ for i in range(7):
+ try:
+ w_item = self.next(w_iterator)
+ except OperationError, e:
+ if not e.match(self, self.w_StopIteration):
+ raise
+ break # done
+ items.append(w_item)
+ return items
return ObjSpace.unpackiterable(self, w_iterable, expected_length)
# ____________________________________________________________
More information about the Pypy-commit
mailing list