Commit a8df29d5 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[utils] Fix encoding/decoding handling when writing to binary/text files

parent 301cafb8
Pipeline #19412 passed with stage
in 19 minutes and 19 seconds
......@@ -190,6 +190,15 @@ class File(object):
mode = 'wb' if self.binary else 'wt'
if self.binary:
mode = 'wb'
if isinstance(contents, six.string_types):
contents = contents.encode('utf-8')
mode = 'wt'
if not isinstance(contents, six.string_types):
contents = contents.decode('utf-8')
with open(self.path, mode) as f:
Supports Markdown
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