From 6bf8bcdffe660f5e42ad3daf4e44f2c6e9779208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Sat, 14 Nov 2020 12:25:21 +0100 Subject: [PATCH] Fix encoding mode for binary files Writing binary files triggered an error: ValueError: binary mode doesn't take an encoding argument --- tutor/env.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tutor/env.py b/tutor/env.py index 4d5931e..2a765cf 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -228,10 +228,12 @@ def write_to(content, path): Write some content to a path. Content can be either str or bytes. """ open_mode = "w" + encoding = "utf8" if isinstance(content, bytes): open_mode += "b" + encoding = None 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)