Commit 1c8fde93 authored by Guido van Rossum's avatar Guido van Rossum

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.
parent f87f135c
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment