Commit 1257fc62 authored by Stefan Behnel's avatar Stefan Behnel

Fix error handling for module init sub-functions, which failed to set the error position correctly.

parent 8142ffab
...@@ -2296,7 +2296,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2296,7 +2296,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.exit_cfunc_scope() # done with labels code.exit_cfunc_scope() # done with labels
def generate_module_init_func(self, imported_modules, env, code): def generate_module_init_func(self, imported_modules, env, code):
subfunction = self.mod_init_subfunction(self.scope, code) subfunction = self.mod_init_subfunction(self.pos, self.scope, code)
code.enter_cfunc_scope(self.scope) code.enter_cfunc_scope(self.scope)
code.putln("") code.putln("")
...@@ -2422,10 +2422,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2422,10 +2422,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if Options.cache_builtins: if Options.cache_builtins:
code.putln("/*--- Builtin init code ---*/") code.putln("/*--- Builtin init code ---*/")
code.put_error_if_neg(None, "__Pyx_InitCachedBuiltins()") code.put_error_if_neg(self.pos, "__Pyx_InitCachedBuiltins()")
code.putln("/*--- Constants init code ---*/") code.putln("/*--- Constants init code ---*/")
code.put_error_if_neg(None, "__Pyx_InitCachedConstants()") code.put_error_if_neg(self.pos, "__Pyx_InitCachedConstants()")
code.putln("/*--- Global type/function init code ---*/") code.putln("/*--- Global type/function init code ---*/")
...@@ -2516,7 +2516,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2516,7 +2516,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.exit_cfunc_scope() code.exit_cfunc_scope()
def mod_init_subfunction(self, scope, orig_code): def mod_init_subfunction(self, pos, scope, orig_code):
""" """
Return a context manager that allows deviating the module init code generation Return a context manager that allows deviating the module init code generation
into a separate function and instead inserts a call to it. into a separate function and instead inserts a call to it.
...@@ -2572,9 +2572,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2572,9 +2572,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("") code.putln("")
if needs_error_handling: if needs_error_handling:
self.call_code.use_label(orig_code.error_label) self.call_code.putln(
self.call_code.putln("if (unlikely(%s() != 0)) goto %s;" % ( self.call_code.error_goto_if_neg("%s()" % self.cfunc_name, pos))
self.cfunc_name, orig_code.error_label))
else: else:
self.call_code.putln("(void)%s();" % self.cfunc_name) self.call_code.putln("(void)%s();" % self.cfunc_name)
self.call_code = None self.call_code = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment