Commit 25a506e3 authored by Robert Bradshaw's avatar Robert Bradshaw

Ticket #216, Exceptions in __Pyx_InitGlobals() lead to a crash

parent d2b2680d
...@@ -1635,6 +1635,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1635,6 +1635,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("{") code.putln("{")
tempdecl_code = code.insertion_point() tempdecl_code = code.insertion_point()
self.generate_filename_init_call(code)
code.putln("#ifdef CYTHON_REFNANNY") code.putln("#ifdef CYTHON_REFNANNY")
code.putln("void* __pyx_refchk = NULL;") code.putln("void* __pyx_refchk = NULL;")
code.putln("__Pyx_Refnanny = __Pyx_ImportRefcountAPI(\"refnanny\");") code.putln("__Pyx_Refnanny = __Pyx_ImportRefcountAPI(\"refnanny\");")
...@@ -1656,7 +1657,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1656,7 +1657,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("/*--- Library function declarations ---*/") code.putln("/*--- Library function declarations ---*/")
env.generate_library_function_declarations(code) env.generate_library_function_declarations(code)
self.generate_filename_init_call(code)
code.putln("/*--- Threads initialization code ---*/") code.putln("/*--- Threads initialization code ---*/")
code.putln("#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS") code.putln("#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS")
...@@ -1665,12 +1665,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1665,12 +1665,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("#endif") code.putln("#endif")
code.putln("#endif") code.putln("#endif")
code.putln("/*--- Initialize various global constants etc. ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitGlobals()", self.pos))
code.putln("/*--- Module creation code ---*/") code.putln("/*--- Module creation code ---*/")
self.generate_module_creation_code(env, code) self.generate_module_creation_code(env, code)
code.putln("/*--- Initialize various global constants etc. ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitGlobals()", self.pos))
if Options.cache_builtins: if Options.cache_builtins:
code.putln("/*--- Builtin init code ---*/") code.putln("/*--- Builtin init code ---*/")
code.putln(code.error_goto_if_neg("__Pyx_InitCachedBuiltins()", code.putln(code.error_goto_if_neg("__Pyx_InitCachedBuiltins()",
...@@ -1710,9 +1710,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1710,9 +1710,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_var_xdecrefs(env.temp_entries) code.put_var_xdecrefs(env.temp_entries)
for cname, type in code.funcstate.all_managed_temps(): for cname, type in code.funcstate.all_managed_temps():
code.put_xdecref(cname, type) code.put_xdecref(cname, type)
code.putln('__Pyx_AddTraceback("%s");' % env.qualified_name) code.putln('if (%s) {' % env.module_cname)
code.putln('__Pyx_AddTraceback("init %s");' % env.qualified_name)
env.use_utility_code(Nodes.traceback_utility_code) env.use_utility_code(Nodes.traceback_utility_code)
code.put_decref_clear(env.module_cname, py_object_type, nanny=False) code.put_decref_clear(env.module_cname, py_object_type, nanny=False)
code.putln('} else if (!PyErr_Occurred()) {')
code.putln('PyErr_SetString(PyExc_ImportError, "init %s");' % env.qualified_name)
code.putln('}')
code.put_label(code.return_label) code.put_label(code.return_label)
code.put_finish_refcount_context() code.put_finish_refcount_context()
......
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