Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44042:8d8d094ff219
Date: 2011-05-09 15:23 +0200
http://bitbucket.org/pypy/pypy/changeset/8d8d094ff219/
Log: - also test other cases, finding another bug.
- fix the two bugs.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -890,8 +890,7 @@
try:
w_res = self.call_args(w_func, args)
except OperationError, e:
- w_value = e.get_w_value(self)
- ec.c_exception_trace(frame, w_value)
+ ec.c_exception_trace(frame, w_func)
raise
ec.c_return_trace(frame, w_func, args)
return w_res
diff --git a/pypy/interpreter/executioncontext.py
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -56,10 +56,10 @@
frame.f_backref = self.topframeref
self.topframeref = jit.virtual_ref(frame)
- def leave(self, frame):
+ def leave(self, frame, w_exitvalue):
try:
if self.profilefunc:
- self._trace(frame, 'leaveframe', self.space.w_None)
+ self._trace(frame, 'leaveframe', w_exitvalue)
finally:
self.topframeref = frame.f_backref
jit.virtual_ref_finish(frame)
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -138,6 +138,7 @@
not self.space.config.translating)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
+ w_exitvalue = self.space.w_None
try:
executioncontext.call_trace(self)
#
@@ -166,7 +167,7 @@
# allocating exception objects in some cases
self.last_exception = None
finally:
- executioncontext.leave(self)
+ executioncontext.leave(self, w_exitvalue)
return w_exitvalue
execute_frame.insert_stack_check_here = True
diff --git a/pypy/interpreter/test/test_executioncontext.py
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -343,3 +343,51 @@
assert l == [('call', None),
('return', 42),
('c_call', sys.setprofile)], repr(l)
+
+ def test_c_return(self):
+ import sys
+ l = []
+ def profile(frame, event, arg):
+ l.append((event, arg))
+
+ sys.setprofile(profile)
+ max(2, 42)
+ sys.setprofile(None)
+ assert l == [('c_call', max),
+ ('c_return', max),
+ ('c_call', sys.setprofile)], repr(l)
+
+ def test_exception(self):
+ import sys
+ l = []
+ def profile(frame, event, arg):
+ l.append((event, arg))
+
+ def f():
+ raise ValueError("foo")
+
+ sys.setprofile(profile)
+ try:
+ f()
+ except ValueError:
+ pass
+ sys.setprofile(None)
+ assert l == [('call', None),
+ ('return', None),
+ ('c_call', sys.setprofile)], repr(l)
+
+ def test_c_exception(self):
+ import sys
+ l = []
+ def profile(frame, event, arg):
+ l.append((event, arg))
+
+ sys.setprofile(profile)
+ try:
+ divmod(5, 0)
+ except ZeroDivisionError:
+ pass
+ sys.setprofile(None)
+ assert l == [('c_call', divmod),
+ ('c_exception', divmod),
+ ('c_call', sys.setprofile)], repr(l)
_______________________________________________
Pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit