[pypy-svn] r61393 - in pypy/trunk/pypy: interpreter module/sys/test
arigo at codespeak.net
arigo at codespeak.net
Tue Jan 27 16:07:23 CET 2009
Author: arigo
Date: Tue Jan 27 16:07:22 2009
New Revision: 61393
Modified:
pypy/trunk/pypy/interpreter/executioncontext.py
pypy/trunk/pypy/module/sys/test/test_sysmodule.py
Log:
(antocuni, arigo)
Fix for sys.settrace() showing sometimes hidden frames too, like the
implementation of execfile(). Done by passing 'frame' explicitly,
instead of re-fetching it -- because executioncontext.framestack.top()
is the last *visible* frame only.
Modified: pypy/trunk/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/trunk/pypy/interpreter/executioncontext.py (original)
+++ pypy/trunk/pypy/interpreter/executioncontext.py Tue Jan 27 16:07:22 2009
@@ -157,7 +157,7 @@
ticker += 1
actionflag.set(ticker)
if ticker & actionflag.interesting_bits: # fast check
- actionflag.action_dispatcher(self) # slow path
+ actionflag.action_dispatcher(self, frame) # slow path
bytecode_trace._always_inline_ = True
def exception_trace(self, frame, operationerr):
@@ -340,7 +340,7 @@
nonperiodic_actions = unrolling_iterable(self._nonperiodic_actions)
has_bytecode_counter = self.has_bytecode_counter
- def action_dispatcher(ec):
+ def action_dispatcher(ec, frame):
# periodic actions
if has_bytecode_counter:
ticker = self.get()
@@ -354,14 +354,14 @@
ticker -= ec.space.sys.checkinterval
self.set(ticker)
for action in periodic_actions:
- action.perform(ec)
+ action.perform(ec, frame)
# nonperiodic actions
for action, bitmask in nonperiodic_actions:
ticker = self.get()
if ticker & bitmask:
self.set(ticker & ~ bitmask)
- action.perform(ec)
+ action.perform(ec, frame)
action_dispatcher._dont_inline_ = True
self.action_dispatcher = action_dispatcher
@@ -414,7 +414,7 @@
from pypy.module.thread.gil import spacestate
spacestate.set_actionflag_bit_after_thread_switch |= self.bitmask
- def perform(self, executioncontext):
+ def perform(self, executioncontext, frame):
"""To be overridden."""
@@ -442,7 +442,7 @@
self.dying_objects_w.append(w_obj)
self.fire()
- def perform(self, executioncontext):
+ def perform(self, executioncontext, frame):
if self.finalizers_lock_count > 0:
return
# Each call to perform() first grabs the self.dying_objects_w
@@ -466,8 +466,7 @@
class FrameTraceAction(AsyncAction):
"""An action that calls the local trace functions (w_f_trace)."""
- def perform(self, executioncontext):
- frame = executioncontext.framestack.top()
+ def perform(self, executioncontext, frame):
if frame.w_f_trace is None or executioncontext.is_tracing:
return
code = frame.pycode
Modified: pypy/trunk/pypy/module/sys/test/test_sysmodule.py
==============================================================================
--- pypy/trunk/pypy/module/sys/test/test_sysmodule.py (original)
+++ pypy/trunk/pypy/module/sys/test/test_sysmodule.py Tue Jan 27 16:07:22 2009
@@ -328,13 +328,13 @@
assert sys.byteorder in ("little", "big")
assert isinstance(sys.builtin_module_names, tuple)
assert isinstance(sys.copyright, basestring)
- assert isinstance(sys.exec_prefix, basestring)
+ #assert isinstance(sys.exec_prefix, basestring) -- not present!
assert isinstance(sys.executable, basestring)
assert isinstance(sys.hexversion, int)
assert isinstance(sys.maxint, int)
assert isinstance(sys.maxunicode, int)
assert isinstance(sys.platform, basestring)
- assert isinstance(sys.prefix, basestring)
+ #assert isinstance(sys.prefix, basestring) -- not present!
assert isinstance(sys.version, basestring)
assert isinstance(sys.warnoptions, list)
vi = sys.version_info
@@ -383,3 +383,20 @@
assert project == 'PyPy'
assert svnbranch == svnbranch.strip('/')
assert revision.isdigit()
+
+ def test_trace_exec_execfile(self):
+ found = []
+ def do_tracing(f, *args):
+ print f.f_code.co_filename, f.f_lineno, args
+ if f.f_code.co_filename == 'foobar':
+ found.append(args[0])
+ return do_tracing
+ co = compile("execfile('this-file-does-not-exist!')",
+ 'foobar', 'exec')
+ sys.settrace(do_tracing)
+ try:
+ exec co in {}
+ except IOError:
+ pass
+ sys.settrace(None)
+ assert found == ['call', 'line', 'exception']
More information about the Pypy-commit
mailing list