summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-18 22:22:25 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-18 22:22:25 (GMT)
commit99d2fbb8236dc792d7e3762cf1d7419405db4752 (patch)
tree4953cba02eb669470adfe42d6c37112705f8497e
parentf499b030bd7bc83e30c03b46ff1a2c7f3e41da93 (diff)
downloadcpython-99d2fbb8236dc792d7e3762cf1d7419405db4752.zip
cpython-99d2fbb8236dc792d7e3762cf1d7419405db4752.tar.gz
cpython-99d2fbb8236dc792d7e3762cf1d7419405db4752.tar.bz2
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.
-rw-r--r--Lib/socket.py13
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):