mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-02-14 06:40:21 +00:00
Fix encoding mode for binary files
Writing binary files triggered an error: ValueError: binary mode doesn't take an encoding argument
This commit is contained in:
parent
c35a0480e1
commit
6bf8bcdffe
@ -228,10 +228,12 @@ def write_to(content, path):
|
|||||||
Write some content to a path. Content can be either str or bytes.
|
Write some content to a path. Content can be either str or bytes.
|
||||||
"""
|
"""
|
||||||
open_mode = "w"
|
open_mode = "w"
|
||||||
|
encoding = "utf8"
|
||||||
if isinstance(content, bytes):
|
if isinstance(content, bytes):
|
||||||
open_mode += "b"
|
open_mode += "b"
|
||||||
|
encoding = None
|
||||||
utils.ensure_file_directory_exists(path)
|
utils.ensure_file_directory_exists(path)
|
||||||
with open(path, open_mode, encoding="utf8") as of:
|
with open(path, open_mode, encoding=encoding) as of:
|
||||||
of.write(content)
|
of.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user