Commit 9aab6383 authored by Stefan Behnel's avatar Stefan Behnel

fix reference leak in case of fatal errors during module setup

parent 4fbcd36e
...@@ -2140,8 +2140,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -2140,8 +2140,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
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('if (%s) {' % env.module_cname) code.putln('if (%s) {' % env.module_cname)
code.putln('if (%s) {' % env.module_dict_cname)
code.put_add_traceback("init %s" % env.qualified_name) code.put_add_traceback("init %s" % env.qualified_name)
env.use_utility_code(Nodes.traceback_utility_code) code.globalstate.use_utility_code(Nodes.traceback_utility_code)
code.put_decref_clear(env.module_dict_cname, py_object_type, nanny=False)
code.putln('}')
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('} else if (!PyErr_Occurred()) {')
code.putln('PyErr_SetString(PyExc_ImportError, "init %s");' % env.qualified_name) code.putln('PyErr_SetString(PyExc_ImportError, "init %s");' % env.qualified_name)
......
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