Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r77039:e24b51be112d
Date: 2015-05-04 14:52 +0200
http://bitbucket.org/pypy/pypy/changeset/e24b51be112d/

Log:    Encode frame_finished_execution in last_instr == -2

diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -97,7 +97,7 @@
                 self.frame = None
                 raise
             # if the frame is now marked as finished, it was RETURNed from
-            if frame.frame_finished_execution:
+            if frame.frame_finished_execution():
                 self.frame = None
                 raise OperationError(space.w_StopIteration, space.w_None)
             else:
@@ -149,7 +149,7 @@
             raise OperationError(space.w_RuntimeError, space.wrap(msg))
 
     def descr_gi_frame(self, space):
-        if self.frame is not None and not self.frame.frame_finished_execution:
+        if self.frame is not None and not 
self.frame.frame_finished_execution():
             return self.frame
         else:
             return space.w_None
@@ -193,7 +193,7 @@
                             raise
                         break
                     # if the frame is now marked as finished, it was RETURNed 
from
-                    if frame.frame_finished_execution:
+                    if frame.frame_finished_execution():
                         break
                     results.append(w_result)     # YIELDed
             finally:
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -56,7 +56,6 @@
 
     __metaclass__ = extendabletype
 
-    frame_finished_execution = False
     last_instr               = -1
     last_exception           = None
     f_backref                = jit.vref_None
@@ -127,6 +126,9 @@
             return None
         return d.w_locals
 
+    def frame_finished_execution(self):
+        return self.last_instr == -2
+
     def __repr__(self):
         # NOT_RPYTHON: useful in tracebacks
         return "<%s.%s executing %s at line %s" % (
@@ -444,7 +446,6 @@
             w_tb,        #
             self.w_globals,
             w(self.last_instr),
-            w(self.frame_finished_execution),
             w(f_lineno),
             w_fastlocals,
             space.w_None,           #XXX placeholder for f_locals
@@ -464,9 +465,9 @@
         from pypy.module._pickle_support import maker # helper fns
         from pypy.interpreter.pycode import PyCode
         from pypy.interpreter.module import Module
-        args_w = space.unpackiterable(w_args, 18)
+        args_w = space.unpackiterable(w_args, 17)
         w_f_back, w_builtin, w_pycode, w_valuestack, w_blockstack, 
w_exc_value, w_tb,\
-            w_globals, w_last_instr, w_finished, w_f_lineno, w_fastlocals, 
w_f_locals, \
+            w_globals, w_last_instr, w_f_lineno, w_fastlocals, w_f_locals, \
             w_f_trace, w_instr_lb, w_instr_ub, w_instr_prev_plus_one, w_cells 
= args_w
 
         new_frame = self
@@ -511,7 +512,6 @@
                                                       w_exc_value, tb
                                                       )
         new_frame.last_instr = space.int_w(w_last_instr)
-        new_frame.frame_finished_execution = space.is_true(w_finished)
         d = new_frame.getorcreatedebug()
         d.f_lineno = space.int_w(w_f_lineno)
         fastlocals_w = maker.slp_from_tuple_with_nulls(space, w_fastlocals)
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -449,7 +449,7 @@
             if (block.handling_mask & unroller_kind) != 0:
                 return block
             block.cleanupstack(self)
-        self.frame_finished_execution = True  # for generators
+        self.last_instr = -2  # makes frame_finished_execution return True
         return None
 
     def unrollstack_and_jump(self, unroller):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to