Skip to content

Commit

Permalink
Drop explicit byte and str conversion on data in fileio write helpers…
Browse files Browse the repository at this point in the history
… now that

mode is intelligently selected to match input data type.
  • Loading branch information
jonasbardino committed May 29, 2024
1 parent 8c21c6f commit e30bfd4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions mig/shared/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ def _write_chunk(path, chunk, offset, logger=None, mode='r+b',
filehandle.write('\0')
# logger.debug('write %s chunk of size %d at position %d' %
# (path, len(chunk), filehandle.tell()))
# NOTE: we may need to force str or bytes here depending on mode
if 'b' in mode:
filehandle.write(force_utf8(chunk))
else:
filehandle.write(force_native_str(chunk))
# NOTE: mode should already be adjusted to chunk string type here
filehandle.write(chunk)
# logger.debug("file %r chunk written at %d" % (path, offset))
return True
except Exception as err:
Expand Down

0 comments on commit e30bfd4

Please sign in to comment.