On Wed, Jun 23, 2010 at 12:46 AM, Stefan Behnel <[email protected]> wrote:
> Haoyu Bai, 22.06.2010 18:29:
>>
>> Indeed, there are
>> some other places that we should use Py_CLEAR() insted of DECREF. I'll
>> try to go through and fix them.
>
> Be careful, though, it's not always the right thing to do. Py_CLEAR() is
> nice for hand written code, but Cython can sometimes do better or has to do
> other things in order to generate correct code. I don't remember where, but
> I already ran into this trap once.
>
> Whatever you change in this regard, please call for a review before you
> invest too much time into it.
>
> Stefan
>

In tp_dealloc we are generating code like this:

  XDECREF(scope->var1);
  XDECREF(scope->var2);
  XDECREF(scope->var3);
  scope->tp_free(scope);

Should we use Py_CLEAR here?


In DefNode.generate_argument_parsing_code(), we are calling
put_var_xdecref_clear() to clean up  closure when error occurs. And
the decref_clear() generates code like

  DECREF(scope->var); scope->var=0;

Should this also be replaced by Py_CLEAR?



-- 
Haoyu BAI
School of Computing,
National University of Singapore.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to