diff options
-rw-r--r-- | Lib/socket.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index b45b4dc..d2ac593 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -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): |