diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2013-08-08 19:49:11 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2013-08-08 19:49:11 +0200 |
commit | b274ea0bfc89ac062cdcd408c8ae49bb06ad883d (patch) | |
tree | 7390f7452b367ab1cdd5a94b208b85f8b2619ed4 /Cython/Compiler/ModuleNode.py | |
parent | 6e1c15baa0c447a7b21ee630596f97ed3362f2e4 (diff) | |
download | cython-b274ea0bfc89ac062cdcd408c8ae49bb06ad883d.tar.gz |
make the NULL-instead-of-None change in tp_clear() optional and off by default - breaks too much code for now
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index d1cc241fb..d4a983389 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1366,6 +1366,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("") code.putln("static int %s(%sPyObject *o) {" % (slot_func, unused)) + if py_attrs and Options.clear_to_none: + code.putln("PyObject* tmp;") + if py_attrs or py_buffers: self.generate_self_cast(scope, code) @@ -1389,8 +1392,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.globalstate.use_utility_code( UtilityCode.load_cached("CallNextTpClear", "ExtensionTypes.c")) - for entry in py_attrs: - code.putln("Py_CLEAR(p->%s);" % entry.cname) + if Options.clear_to_none: + for entry in py_attrs: + name = "p->%s" % entry.cname + code.putln("tmp = ((PyObject*)%s);" % name) + if entry.is_declared_generic: + code.put_init_to_py_none(name, py_object_type, nanny=False) + else: + code.put_init_to_py_none(name, entry.type, nanny=False) + code.putln("Py_XDECREF(tmp);") + else: + for entry in py_attrs: + code.putln("Py_CLEAR(p->%s);" % entry.cname) for entry in py_buffers: # Note: shouldn't this call __Pyx_ReleaseBuffer ?? |