From 01607f4673df103570167ce6b7e5cef4718fe589 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 13 Oct 2009 20:05:21 +0200 Subject: [PATCH] fix ticket #346 --- Cython/Compiler/Nodes.py | 5 +++-- tests/run/funcexceptraise.pyx | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/run/funcexceptraise.pyx 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 -- 2.26.2