From c1a4f4148dcb8ed984ab3b1cfe117f194ce468ea Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 4 Aug 2013 15:13:54 +0200 Subject: [PATCH] minor code cleanup --- Cython/Compiler/ModuleNode.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 6fe933b..9e51e0b 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1256,12 +1256,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if not scope.needs_finalisation(): return - entry = scope.lookup_here("__dealloc__") - if entry: - dealloc_user_cfunc = entry.func_cname - else: - dealloc_user_cfunc = None - weakref_slot = scope.lookup_here("__weakref__") if weakref_slot not in scope.var_entries: weakref_slot = None @@ -1274,7 +1268,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if py_attrs or memoryview_slices or weakref_slot: self.generate_self_cast(scope, code) - if dealloc_user_cfunc: + entry = scope.lookup_here("__dealloc__") + if entry: code.putln("PyObject *etype, *eval, *etb;") code.putln("PyErr_Fetch(&etype, &eval, &etb);") @@ -1282,7 +1277,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("++Py_REFCNT(o);") code.putln("#endif") - code.putln("%s(o);" % dealloc_user_cfunc) + code.putln("%s(o);" % entry.func_cname) code.putln("if (PyErr_Occurred()) PyErr_WriteUnraisable(o);") code.putln("#if PY_VERSION_HEX < 0x030400a1") -- 2.7.4