Author: Armin Rigo <[email protected]>
Branch:
Changeset: r71012:d083e472a6ab
Date: 2014-04-27 10:40 +0200
http://bitbucket.org/pypy/pypy/changeset/d083e472a6ab/
Log: issue1743: fix for a726eef8da83
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -299,9 +299,13 @@
"""
self._application_traceback = traceback
[email protected]()
+
+class ClearedOpErr:
+ def __init__(self, space):
+ self.operr = OperationError(space.w_None, space.w_None)
+
def get_cleared_operation_error(space):
- return OperationError(space.w_None, space.w_None)
+ return space.fromcache(ClearedOpErr).operr
# ____________________________________________________________
# optimization only: avoid the slowest operation -- the string
diff --git a/pypy/interpreter/executioncontext.py
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -205,11 +205,14 @@
def sys_exc_info(self): # attn: the result is not the wrapped
sys.exc_info() !!!
"""Implements sys.exc_info().
Return an OperationError instance or None."""
- frame = self.gettopframe_nohidden()
+ frame = self.gettopframe()
while frame:
if frame.last_exception is not None:
- return frame.last_exception
- frame = self.getnextframe_nohidden(frame)
+ if (not frame.hide() or
+ frame.last_exception is
+ get_cleared_operation_error(self.space)):
+ return frame.last_exception
+ frame = frame.f_backref()
return None
def set_sys_exc_info(self, operror):
diff --git a/pypy/module/_continuation/interp_continuation.py
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -1,6 +1,6 @@
from rpython.rlib.rstacklet import StackletThread
from rpython.rlib import jit
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, get_cleared_operation_error
from pypy.interpreter.executioncontext import ExecutionContext
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.typedef import TypeDef
@@ -39,6 +39,7 @@
bottomframe.locals_stack_w[1] = w_callable
bottomframe.locals_stack_w[2] = w_args
bottomframe.locals_stack_w[3] = w_kwds
+ bottomframe.last_exception = get_cleared_operation_error(space)
self.bottomframe = bottomframe
#
global_state.origin = self
diff --git a/pypy/module/_continuation/test/test_stacklet.py
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -684,3 +684,17 @@
execfile(self.translated, d)
d['set_fast_mode']()
d['test_various_depths']()
+
+ def test_exc_info_doesnt_follow_continuations(self):
+ import sys
+ from _continuation import continulet
+ #
+ def f1(c1):
+ return sys.exc_info()
+ #
+ c1 = continulet(f1)
+ try:
+ 1 // 0
+ except ZeroDivisionError:
+ got = c1.switch()
+ assert got == (None, None, None)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit