From: Stefan Behnel Date: Thu, 4 Sep 2008 07:02:19 +0000 (+0200) Subject: fixed utility code integration for try-except X-Git-Tag: 0.9.9.2.beta~63^2~12^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f767831fea383ab14bacfd387ea0ec92c3462674;p=cython.git fixed utility code integration for try-except --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 94c852e3..f7c14711 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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 index 00000000..e4759ba7 --- /dev/null +++ b/tests/run/moduletryexcept.pyx @@ -0,0 +1,15 @@ +__doc__ = u""" +>>> a +2 +""" + +a = 0 + +try: + raise KeyError +except AttributeError: + a = 1 +except KeyError: + a = 2 +except: + a = 3