From f7c25fe4bc6347bb0c81571d1c25bb473838cceb Mon Sep 17 00:00:00 2001 From: Nikita Nemkin <nikita@nemkin.ru> Date: Sat, 6 Apr 2013 16:13:35 +0600 Subject: [PATCH] Consistently declare local error reporting variables (lineno, clineno, filename) for all types of functions. --- Cython/Compiler/Code.py | 6 ++++++ Cython/Compiler/Nodes.py | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 807e6e050..8d194df6a 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -1618,6 +1618,12 @@ class CCodeWriter(object): else: self.putln("%s%s;" % (static and "static " or "", decl)) + if func_context.should_declare_error_indicator: + # Initialize these variables to silence compiler warnings + self.putln("int %s = 0;" % Naming.lineno_cname) + self.putln("const char *%s = NULL;" % Naming.filename_cname) + self.putln("int %s = 0;" % Naming.clineno_cname) + def put_h_guard(self, guard): self.putln("#ifndef %s" % guard) self.putln("#define %s" % guard) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index dcbfbf765..9eecf202d 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1914,13 +1914,6 @@ class FuncDefNode(StatNode, BlockNode): # ----- Go back and insert temp variable declarations tempvardecl_code.put_temp_declarations(code.funcstate) - if code.funcstate.should_declare_error_indicator: - # Initialize these variables to silence compiler warnings - tempvardecl_code.putln("int %s = 0;" % Naming.lineno_cname) - tempvardecl_code.putln("const char *%s = NULL;" % - Naming.filename_cname) - if code.c_line_in_traceback: - tempvardecl_code.putln("int %s = 0;" % Naming.clineno_cname) # ----- Python version code.exit_cfunc_scope() -- 2.30.9