[pypy-svn] pypy default: Fix the test. Maybe that's marginally too much code for such a

arigo commits-noreply at bitbucket.org
Wed Feb 9 19:55:35 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41757:1bf35a5504c8
Date: 2011-02-09 19:55 +0100
http://bitbucket.org/pypy/pypy/changeset/1bf35a5504c8/

Log:	Fix the test. Maybe that's marginally too much code for such a
	corner case, but well, you never know who is going to rely on it.

diff --git a/pypy/interpreter/test/test_pyframe.py b/pypy/interpreter/test/test_pyframe.py
--- a/pypy/interpreter/test/test_pyframe.py
+++ b/pypy/interpreter/test/test_pyframe.py
@@ -441,7 +441,6 @@
         assert res == 42
 
     def test_set_unset_f_trace(self):
-        skip("in-progress, but not too important")
         import sys
         seen = []
         def trace1(frame, what, arg):

diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -209,6 +209,7 @@
         """Set the global trace function."""
         if self.space.is_w(w_func, self.space.w_None):
             self.w_tracefunc = None
+            self.space.frame_trace_action.unfire()
         else:
             self.force_all_frames()
             self.w_tracefunc = w_func
@@ -357,6 +358,15 @@
             # to run at the next possible bytecode
             self.reset_ticker(-1)
 
+    def unfire(self, action):
+        """Cancel the action, if scheduled."""
+        alist = self.fired_actions
+        if alist is not None:
+            for i in range(len(alist)-1, -1, -1):
+                if alist[i] is action:
+                    del alist[i]
+        action._fired = False
+
     def register_periodic_action(self, action, use_bytecode_counter):
         """NOT_RPYTHON:
         Register the PeriodicAsyncAction action to be called whenever the
@@ -439,6 +449,10 @@
         The action must have been registered at space initalization time."""
         self.space.actionflag.fire(self)
 
+    def unfire(self):
+        """Cancel the action, if scheduled."""
+        self.space.actionflag.unfire(self)
+
     def fire_after_thread_switch(self):
         """Bit of a hack: fire() the action but only the next time the GIL
         is released and re-acquired (i.e. after a potential thread switch).


More information about the Pypy-commit mailing list