mirror of https://github.com/python/cpython
I saw errors from _fileobject.__del__ about missing self._sock. This
can happen if __init__ doesn't complete. Fix it by adding a try/except to __del__.
This commit is contained in:
parent
bb1861a996
commit
65f8cedd4a
|
@ -232,7 +232,11 @@ class _fileobject(object):
|
||||||
self._sock = None
|
self._sock = None
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
try:
|
||||||
|
self.close()
|
||||||
|
except:
|
||||||
|
# close() may fail if __init__ didn't complete
|
||||||
|
pass
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
if self._wbuf:
|
if self._wbuf:
|
||||||
|
|
Loading…
Reference in New Issue