Skip to content

Commit

Permalink
S3fs is not based on those, so implement a try/catch solution
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-fsn committed Jun 16, 2021
1 parent 4224e75 commit 7d7a50b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions df_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ def flush_and_close(f):
f = _writer_wrapper(writer, f, writer_args, writer_options)
# we have to write a newline after every rounds, so won't get
# the new round started in the same line
# wrapper can return binary or text, act accordingly
if isinstance(f, (io.RawIOBase, io.BufferedIOBase)):
try:
# Try to adapt to the required mode by catching TypeError
# Seems to be more reliable than trying to figure out the
# binary/text type.
f.write(b'\n')
else:
except TypeError:
f.write('\n')
else:
# in all other cases we're just calling the writer
_writer_wrapper(writer, f, writer_args, writer_options)
flush_and_close(f)


__version__ = '0.0.5'
__version__ = '0.0.6'

0 comments on commit 7d7a50b

Please sign in to comment.