[pypy-commit] pypy translation-cleanup: Flowspacify FOR_ITER

rlamy noreply at buildbot.pypy.org
Mon Sep 24 02:47:14 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57494:d05e9dc3d4e9
Date: 2012-09-23 23:50 +0100
http://bitbucket.org/pypy/pypy/changeset/d05e9dc3d4e9/

Log:	Flowspacify FOR_ITER

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -541,6 +541,20 @@
         # isn't popped straightaway.
         self.pushvalue(None)
 
+    def FOR_ITER(self, jumpby, next_instr):
+        w_iterator = self.peekvalue()
+        try:
+            w_nextitem = self.space.next(w_iterator)
+        except FSException, e:
+            if not self.space.exception_match(e.w_type, self.space.w_StopIteration):
+                raise
+            # iterator exhausted
+            self.popvalue()
+            next_instr += jumpby
+        else:
+            self.pushvalue(w_nextitem)
+        return next_instr
+
     def SETUP_WITH(self, offsettoend, next_instr):
         # A simpler version than the 'real' 2.7 one:
         # directly call manager.__enter__(), don't use special lookup functions


More information about the pypy-commit mailing list