]> granicus.if.org Git - python/commitdiff
Use ``0'' instead of ``None'' to reset the underlying object in close
authorGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:32:59 +0000 (17:32 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:32:59 +0000 (17:32 +0000)
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

index 7e1b3727b22d353dbb6ddf4e0f53bde4bc28b22a..645d01e32fdaf79a37523416c8bd092a29417019 100755 (executable)
@@ -27,7 +27,7 @@ class _socketobject:
        self._sock = sock
 
     def close(self):
-       self._sock = None
+       self._sock = 0
 
     def __del__(self):
        self.close()
@@ -68,7 +68,7 @@ class _fileobject:
            if self._sock:
                self.flush()
        finally:
-           self._sock = None
+           self._sock = 0
 
     def __del__(self):
        self.close()