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:
parent
f499b030bd
commit
99d2fbb823
|
@ -129,11 +129,16 @@ _socketmethods = (
|
||||||
|
|
||||||
class _socketobject:
|
class _socketobject:
|
||||||
|
|
||||||
|
class _closedsocket:
|
||||||
|
def __getattr__(self, name):
|
||||||
|
raise error(9, 'Bad file descriptor')
|
||||||
|
|
||||||
def __init__(self, sock):
|
def __init__(self, sock):
|
||||||
self._sock = sock
|
self._sock = sock
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._sock = _closedsocket()
|
# Avoid referencing globals here
|
||||||
|
self._sock = self.__class__._closedsocket()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -153,12 +158,6 @@ class _socketobject:
|
||||||
exec _s % (_m, _m)
|
exec _s % (_m, _m)
|
||||||
|
|
||||||
|
|
||||||
class _closedsocket:
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
raise error(9, 'Bad file descriptor')
|
|
||||||
|
|
||||||
|
|
||||||
class _fileobject:
|
class _fileobject:
|
||||||
|
|
||||||
def __init__(self, sock, mode, bufsize):
|
def __init__(self, sock, mode, bufsize):
|
||||||
|
|
Loading…
Reference in New Issue