fixed utility code integration for try-except
authorStefan Behnel <scoder@users.berlios.de>
Thu, 4 Sep 2008 07:02:19 +0000 (09:02 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 4 Sep 2008 07:02:19 +0000 (09:02 +0200)
Cython/Compiler/Nodes.py
tests/run/moduletryexcept.pyx [new file with mode: 0644]

index 94c852e3d89dd0dc13ee9d8480625ea128f0fab5..f7c14711fce3e0a1c8e4fbdd89bd5eaf1c57443c 100644 (file)
@@ -3527,7 +3527,6 @@ class TryExceptStatNode(StatNode):
         if self.else_clause:
             self.else_clause.analyse_control_flow(env)
         env.finish_branching(self.end_pos())
-        env.use_utility_code(reset_exception_utility_code)
 
     def analyse_declarations(self, env):
         self.body.analyse_declarations(env)
@@ -3536,6 +3535,7 @@ class TryExceptStatNode(StatNode):
         if self.else_clause:
             self.else_clause.analyse_declarations(env)
         self.gil_check(env)
+        env.use_utility_code(reset_exception_utility_code)
     
     def analyse_expressions(self, env):
         self.body.analyse_expressions(env)
diff --git a/tests/run/moduletryexcept.pyx b/tests/run/moduletryexcept.pyx
new file mode 100644 (file)
index 0000000..e4759ba
--- /dev/null
@@ -0,0 +1,15 @@
+__doc__ = u"""
+>>> a
+2
+"""
+
+a = 0
+
+try:
+    raise KeyError
+except AttributeError:
+    a = 1
+except KeyError:
+    a = 2
+except:
+    a = 3