Author: Antonio Cuni <[email protected]>
Branch: invalidate-virtualrefs
Changeset: r44482:010bf8715e0e
Date: 2011-05-25 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/010bf8715e0e/

Log:    mark the frame as escaped in case we call sys.exc_info(), which
        returns the traceback

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
@@ -131,6 +131,21 @@
         except:
             g(sys.exc_info())
 
+    def test_virtualref_through_traceback(self):
+        import sys
+        def g():
+            try:
+                raise ValueError
+            except:
+                _, _, tb = sys.exc_info()
+            return tb
+        def f():
+            return g()
+        #
+        tb = f()
+        assert tb.tb_frame.f_code.co_name == 'g'
+        assert tb.tb_frame.f_back.f_code.co_name == 'f'
+
     def test_trace_basic(self):
         import sys
         l = []
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -91,6 +91,7 @@
     if operror is None:
         return space.newtuple([space.w_None,space.w_None,space.w_None])
     else:
+        operror.application_traceback.frame.mark_as_escaped()
         return space.newtuple([operror.w_type, operror.get_w_value(space),
                                space.wrap(operror.application_traceback)])
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to