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

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

2
docs

Submodule docs updated: e8b9361615...8d04b2e1f3

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)