Force to "backslashreplace" when UnicodeEncodeError arises when writing file // Issue #2796

This commit is contained in:
Ivan Kravets committed 2019-10-18 15:20:52 +03:00
1 parent 92d86192aa
commit f5807364e8
2 files changed
+2 -2

No files matched your search

+1 -1
Submodule docs updated: e8b9361615...8d04b2e1f3.
+1 -1
View File
@@ -63,7 +63,7 @@ def write_file_contents(path, contents):
with open(path, "w") as fp:
return fp.write(contents)
except UnicodeEncodeError:
with io.open(path, "w", encoding="latin-1") as fp:
with io.open(path, "w", encoding="latin-1", errors="backslashreplace") as fp:
return fp.write(contents)