Lisandro Dalcin wrote: > Since Dag's refnanny was integrated in cython-devel, > test/run/tryfinally.pyx was failing because of reference count errors. > > The patch below is the only way I can imagine to fix such problem. I > expect the patch could be controversial...
Me and Stefan should be OK with it at least: See #200 in trac. (Whether you initialize to Py_None or NULL is a finer point I suppose, I don't have a feeling either way). To avoid the XDECREF in most situations one could make it depend on a flag in ReturnStatNode and write a transform in Optimize.py which turns on the flag on all return nodes in functions which contain return nodes within finally clauses. But that could be done later if this fix is pushed now. Dag Sverre > > > diff -r 3b522098d133 Cython/Compiler/Nodes.py > --- a/Cython/Compiler/Nodes.py Sun Feb 08 09:25:28 2009 +0100 > +++ b/Cython/Compiler/Nodes.py Mon Feb 09 18:22:21 2009 -0200 > @@ -1054,6 +1054,8 @@ > code.put_var_declarations(lenv.var_entries) > init = "" > if not self.return_type.is_void: > + if self.return_type.is_pyobject: > + init = " = NULL" > code.putln( > "%s%s;" % > (self.return_type.declaration_code( > @@ -3371,6 +3373,9 @@ > if self.value: > self.value.generate_evaluation_code(code) > self.value.make_owned_reference(code) > + if self.return_type.is_pyobject: > + code.put_xdecref(Naming.retval_cname, > + self.return_type) > code.putln( > "%s = %s;" % ( > Naming.retval_cname, > -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
