Commit 4c77de2b authored by Stefan Behnel's avatar Stefan Behnel

generate safer cleanup code that also works in the case something goes badly...

generate safer cleanup code that also works in the case something goes badly wrong early at module init time

--HG--
extra : rebase_source : 015495e6aee6c59b11ee9169d2ad597ff54bfd0c
parent cc788b95
......@@ -2010,23 +2010,28 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for entry in rev_entries:
if entry.visibility != 'extern':
if entry.type.is_pyobject and entry.used:
code.putln("Py_DECREF(%s); %s = 0;" % (
code.entry_as_pyobject(entry), entry.cname))
code.put_decref_clear(entry.cname,
entry.type,
clear_before_decref=True,
nanny=False)
code.putln("__Pyx_CleanupGlobals();")
if Options.generate_cleanup_code >= 3:
code.putln("/*--- Type import cleanup code ---*/")
for type, _ in env.types_imported.items():
code.putln("Py_DECREF((PyObject *)%s); %s = 0;" % (
type.typeptr_cname, type.typeptr_cname))
code.put_decref_clear(type.typeptr_cname, type,
clear_before_decref=True,
nanny=False)
if Options.cache_builtins:
code.putln("/*--- Builtin cleanup code ---*/")
for entry in env.cached_builtins:
code.put_decref_clear(entry.cname,
PyrexTypes.py_object_type,
clear_before_decref=True,
nanny=False)
code.putln("/*--- Intern cleanup code ---*/")
code.put_decref_clear(Naming.empty_tuple,
PyrexTypes.py_object_type,
clear_before_decref=True,
nanny=False)
# for entry in env.pynum_entries:
# code.put_decref_clear(entry.cname,
......
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