diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 807e6e05013a242216855ebf297c3e2e6fe9f179..8d194df6a7a698d0a9c5c0bfc7cc09c7ae5374e4 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 dcbfbf76534df822a165884017e5866041284a37..9eecf202dbdc018c160c1c21e1371b945c2181d1 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()