Move the helper class _closedsocket *into* the _socketobject class.

This way, when a socket object is deleted after the socket module has
already been zapped by module shutdown, we don't get annoying warnings
about exceptions in __del__ methods.
This commit is contained in:
Guido van Rossum 2001-12-18 22:22:25 +00:00
parent f499b030bd
commit 99d2fbb823
1 changed files with 6 additions and 7 deletions

View File

@ -129,11 +129,16 @@ _socketmethods = (
class _socketobject:
class _closedsocket:
def __getattr__(self, name):
raise error(9, 'Bad file descriptor')
def __init__(self, sock):
self._sock = sock
def close(self):
self._sock = _closedsocket()
# Avoid referencing globals here
self._sock = self.__class__._closedsocket()
def __del__(self):
self.close()
@ -153,12 +158,6 @@ class _socketobject:
exec _s % (_m, _m)
class _closedsocket:
def __getattr__(self, name):
raise error(9, 'Bad file descriptor')
class _fileobject:
def __init__(self, sock, mode, bufsize):