[issue26590] socket destructor: implement finalizer

Antoine Pitrou report at bugs.python.org
Sat Mar 19 09:15:09 EDT 2016


Antoine Pitrou added the comment:

Le 19/03/2016 14:07, STINNER Victor a écrit :
> 
> Example:
> ---
> import socket
> s=socket.socket()
> s=None
> ---
> 
> With this code, sock_finalize() is called before sock_dealloc():
> 
> #0  sock_finalize (s=0x7ffff0730c28) at
> /home/haypo/prog/python/default/Modules/socketmodule.c:4172
> #1  0x00000000004d8f59 in PyObject_CallFinalizer (self=<socket at
> remote 0x7ffff0730c28>) at Objects/object.c:294
> #2  0x00000000004d8fcd in PyObject_CallFinalizerFromDealloc
> (self=<socket at remote 0x7ffff0730c28>) at Objects/object.c:311
> #3  0x00000000004f2c8f in subtype_dealloc (self=<socket at remote
> 0x7ffff0730c28>) at Objects/typeobject.c:1154

Ah, that's probably because socket.socket is a Python subclass.
What happens if you use _socket.socket directly instead?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26590>
_______________________________________


More information about the Python-bugs-list mailing list