From f767831fea383ab14bacfd387ea0ec92c3462674 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 4 Sep 2008 09:02:19 +0200 Subject: [PATCH] fixed utility code integration for try-except --- Cython/Compiler/Nodes.py | 2 +- tests/run/moduletryexcept.pyx | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/run/moduletryexcept.pyx 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 -- 2.26.2