From 19f44560f2387fd0f7e7f6b459510428216b6f79 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Nov 1997 17:32:59 +0000 Subject: [PATCH] Use ``0'' instead of ``None'' to reset the underlying object in close methods. Using None causes problems if the destructor is called after the __builtin__ module has already been destroyed (unfortunately, this can happen!). I can't just delete the object because it is actually tested for (if self._sock: ...). Setting it to 0 is a bit weird but works. --- Lib/plat-win/socket.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/plat-win/socket.py b/Lib/plat-win/socket.py index 7e1b3727b22..645d01e32fd 100755 --- a/Lib/plat-win/socket.py +++ b/Lib/plat-win/socket.py @@ -27,7 +27,7 @@ def __init__(self, sock): self._sock = sock def close(self): - self._sock = None + self._sock = 0 def __del__(self): self.close() @@ -68,7 +68,7 @@ def close(self): if self._sock: self.flush() finally: - self._sock = None + self._sock = 0 def __del__(self): self.close()