From: Stefan Behnel Date: Tue, 13 Oct 2009 18:05:21 +0000 (+0200) Subject: fix ticket #346 X-Git-Tag: 0.13.beta0~2^2~121^2~69 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=01607f4673df103570167ce6b7e5cef4718fe589;p=cython.git fix ticket #346 --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 25912168..3d671d42 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -4137,8 +4137,9 @@ class TryExceptStatNode(StatNode): if error_label_used or not self.has_default_clause: if error_label_used: code.put_label(except_error_label) - for var in Naming.exc_save_vars: - code.put_xdecref(var, py_object_type) + for var in Naming.exc_save_vars: code.put_xgiveref(var) + code.putln("__Pyx_ExceptionReset(%s);" % + ', '.join(Naming.exc_save_vars)) code.put_goto(old_error_label) for exit_label, old_label in zip( diff --git a/tests/run/funcexceptraise.pyx b/tests/run/funcexceptraise.pyx new file mode 100644 index 00000000..900eee04 --- /dev/null +++ b/tests/run/funcexceptraise.pyx @@ -0,0 +1,19 @@ +__doc__ = u""" +>>> def bar(): +... try: +... foo() +... except ValueError: +... pass + +>>> bar() +>>> print(sys.exc_info()) +(None, None, None) +""" + +import sys + +def foo(): + try: + raise TypeError + except TypeError: + raise ValueError