This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: minor inconsistency in socket.close
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: ellisj, jhylton, mark-roberts
Priority: normal Keywords:

Created on 2006-12-22 18:05 by ellisj, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg30851 - (view) Author: Jonathan Ellis (ellisj) Date: 2006-12-22 18:05
In python 2.5 socket.close, all methods are delegated to _dummy, which raises an error.  It would be more consistent to delegate each method to its counterpart in _closedsocket; in particular re-closing a closed socket is not intended to raise:

    def close(self):
        self._sock.close()
        self._sock = _closedsocket()
        for method in _delegate_methods:
            setattr(self, method, getattr(self._sock, method))
msg30852 - (view) Author: Mark Roberts (mark-roberts) Date: 2007-01-20 01:51
On trunk:

>>> import socket
>>> s=socket.socket()
>>> s.close()
>>> s.close()
>>> 

It also seems that the following line will make even that remapping not useful?  Isn't it better just to avoid the layer of indirection and directly proceed with assigning to _dummy?

line 145: send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
msg30853 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2007-02-25 22:48
Re-closing a socket does not raise an exception.  If there is something else in your bug report that I am missing, please re-open it.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44372
2006-12-22 18:05:03ellisjcreate