mirror of
https://github.com/python/cpython.git
synced 2025-12-10 19:10:59 +00:00
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.
This commit is contained in:
parent
8f3c812e22
commit
19f44560f2
1 changed files with 2 additions and 2 deletions
|
|
@ -27,7 +27,7 @@ class _socketobject:
|
||||||
self._sock = sock
|
self._sock = sock
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._sock = None
|
self._sock = 0
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
@ -68,7 +68,7 @@ class _fileobject:
|
||||||
if self._sock:
|
if self._sock:
|
||||||
self.flush()
|
self.flush()
|
||||||
finally:
|
finally:
|
||||||
self._sock = None
|
self._sock = 0
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue