Stefan Behnel wrote:
> Hi again,
> 
>> @@ -1231,15 +1233,14 @@
>>              if default:
>>                  if not default.is_literal:
>>                      default.generate_evaluation_code(code)
>> -                    default.make_owned_reference(code)
>> -                    code.putln(
>> -                        "%s = %s;" % (
>> -                            arg.default_entry.cname,
>> -                            default.result_as(arg.default_entry.type)))
>> -                    if default.is_temp and default.type.is_pyobject:
>> -                        code.putln(
>> -                            "%s = 0;" %
>> -                                default.result())
>> +                    assign_code = "%s = %s;" % (
>> +                        arg.default_entry.cname,
>> +                        default.result_as(arg.default_entry.type))
>> +                    if default.type.is_pyobject:
>> +                        assign_code += " Py_INCREF(%s);" % \
>> +                            arg.type.as_pyobject(arg.default_entry.cname)
>> +                    code.putln(assign_code)
>> +                    default.generate_disposal_code(code)
>>                      default.free_temps(code)
> 
> Here's what I pushed now (Nodes.py):
> 
>             if default:
>                 if not default.is_literal:
>                     default.generate_evaluation_code(code)
>                     default.make_owned_reference(code)
>                     code.putln(
>                         "%s = %s;" % (
>                             arg.default_entry.cname,
>                             default.result_as(arg.default_entry.type)))
>                     if default.is_temp and default.type.is_pyobject:
>                         code.putln("%s = 0;" % default.result())
>                     default.free_temps(code)
>                     code.put_giveref(arg.default_entry.cname)
> 
> Note that generate_evaluation_code() already cleans up the temps of the RHS
> subexpressions, so there is no need to do anything but stealing the reference.

+1; at least dropping that call to make_owned_reference was asking for 
trouble (as I suppose the object could or could not own the reference, 
and that could be a noop or not a noop, depending on circumstances)

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to