Commit c3148641 by rfkelly0

cleanup FileWrapper.__del__ a little

parent 7d801b21
......@@ -618,11 +618,11 @@ class FileWrapper(FileLikeBase):
# Close the wrapper and the underlying file independently, so the
# latter is still closed on cleanup even if the former errors out.
try:
if FileWrapper is not None:
super(FileWrapper,self).close()
except Exception:
finally:
if hasattr(getattr(self,"wrapped_file",None),"close"):
self.wrapped_file.close()
raise
def close(self):
"""Close the object for reading/writing."""
......@@ -631,6 +631,7 @@ class FileWrapper(FileLikeBase):
# close() on it, which will call its flush() again! To avoid
# this inefficiency, our flush() will not flush the wrapped
# file when we're closing.
if not self.closed:
self.__closing = True
super(FileWrapper,self).close()
if hasattr(self.wrapped_file,"close"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment