fix ticket #346
authorStefan Behnel <scoder@users.berlios.de>
Tue, 13 Oct 2009 18:05:21 +0000 (20:05 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 13 Oct 2009 18:05:21 +0000 (20:05 +0200)
Cython/Compiler/Nodes.py
tests/run/funcexceptraise.pyx [new file with mode: 0644]

index 259121687314856bdb7a33a0e4075f5c329df32a..3d671d428f8bed594236e5141b20efcc296a819c 100644 (file)
@@ -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 (file)
index 0000000..900eee0
--- /dev/null
@@ -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