On 03/17, Terry Reedy wrote:
>
> On 3/17/2017 10:54 AM, Oleg Nesterov wrote:
>> I started to learn python a few days ago and I am trying to understand what
>> __del__() actually does. https://docs.python.org/3/reference/datamodel.html
>> says:
>>
>>      object.__del__(self)
>>      ...
>>      Note that it is possible (though not recommended!) for the __del__()
>>      method to postpone destruction of the instance by creating a new
>>      reference to it.
>
> If I understand the below, 'that persists after the function call'
> should be added.

Yes,

> Note that the function call itself 'creates a new
> reference' by binding 'self' to the obj.

Well, not really if I have read this code correctly (quite possibly not),
PyObject_CallFinalizer() is called with the "artificial" ob_refcnt == 1
after it was already zero, and I am not sure call_unbound_noarg() binds
"self", but this doesn't mattter at all afaics.

> I suspect that this was added after the doc.  If git has an annotate
> function, you could check.

I did. And it is not clear to me if this behavioural change was intentional
or not. I don't have the sources right now so I can't tell you the commit id,
I can do this later when I return home.

I have python2.5 on my working laptop, the test-case works as documented.

Oleg.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to