Consistently declare local error reporting variables (lineno, clineno, filename)...
authorNikita Nemkin <nikita@nemkin.ru>
Sat, 6 Apr 2013 10:13:35 +0000 (16:13 +0600)
committerNikita Nemkin <nikita@nemkin.ru>
Sat, 6 Apr 2013 10:13:35 +0000 (16:13 +0600)
Cython/Compiler/Code.py
Cython/Compiler/Nodes.py

index 807e6e0..8d194df 100644 (file)
@@ -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)
index dcbfbf7..9eecf20 100644 (file)
@@ -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()