[pypy-commit] pypy default: A test for hidden_applevel code objects, and fixing the fact that
arigo
noreply at buildbot.pypy.org
Sun Sep 11 15:52:09 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r47202:4c296bad5568
Date: 2011-09-11 14:48 +0200
http://bitbucket.org/pypy/pypy/changeset/4c296bad5568/
Log: A test for hidden_applevel code objects, and fixing the fact that
the 'f_back' attribute of frames might return a hidden frame.
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -614,7 +614,8 @@
return self.get_builtin().getdict(space)
def fget_f_back(self, space):
- return self.space.wrap(self.f_backref())
+ f_backref = ExecutionContext.getnextframe_nohidden(self)
+ return self.space.wrap(f_backref)
def fget_f_lasti(self, space):
return self.space.wrap(self.last_instr)
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
@@ -6,6 +6,14 @@
def setup_class(cls):
cls.w_udir = cls.space.wrap(str(udir.udir))
cls.w_tempfile1 = cls.space.wrap(str(udir.udir.join('tempfile1')))
+ w_call_further = cls.space.appexec([], """():
+ def call_further(f):
+ return f()
+ return call_further
+ """)
+ assert not w_call_further.code.hidden_applevel
+ w_call_further.code.hidden_applevel = True # hack
+ cls.w_call_further = w_call_further
# test for the presence of the attributes, not functionality
@@ -107,6 +115,20 @@
frame = f()
assert frame.f_back.f_code.co_name == 'f'
+ def test_f_back_hidden(self):
+ import sys
+ def f():
+ return (sys._getframe(0),
+ sys._getframe(1),
+ sys._getframe(0).f_back)
+ def main():
+ return self.call_further(f)
+ f0, f1, f1bis = main()
+ assert f0.f_code.co_name == 'f'
+ assert f1.f_code.co_name == 'main'
+ assert f1bis is f1
+ assert f0.f_back is f1
+
def test_f_exc_xxx(self):
import sys
More information about the pypy-commit
mailing list