◐ Shell
clean mode source ↗

Message 60385 - Python tracker

It appears that 2.3 changed how socket.close() works. 
We now find errors when terminating Python when we 
reference socket.close() in a __del__ method. We have 
worked around it by removing calls to socket.close() but 
note the following differences between the same section 
of code between 2.2 and 2.3 which suggest that the 2.3 
behavior is not ideal and should be fixed.

In Python 2.3:

    def close(self):
        self._sock = _closedsocket()
        self.send = self.recv = self.sendto = self.recvfrom \
                        = self._sock._dummy

In Python 2.2:

    def close(self):
        # Avoid referencing globals here
        self._sock = self.__class__._closedsocket()

Note the reference to avoiding globals which is 
presumably the source of the problem with 2.3. Perhaps 
I'm naive but I would guess that calling a close method 
should be considered a safe operation for use in a 
__del__ method.