def _close(self):
<EOL>try:<EOL><INDENT>self._file.flush()<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>if self._own_file:<EOL><INDENT>self._file.close()<EOL><DEDENT>
Close the file if it was created by the writer.

If a buffer or file-like object was passed in, for example a GzipFile,
then leave this file open for the caller to close. In either case,
attempt to flush the file contents to ensure they are written to disk
(if supported)