From: Zsolt Dollenstein Date: Thu, 12 Apr 2018 18:19:21 +0000 (+0100) Subject: Open temporary files with utf-8 encoding (#126) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/8e7848c63efe36f09e4651bece8c0efc34a1c3e1?ds=inline Open temporary files with utf-8 encoding (#126) This is not the default on Windows. --- diff --git a/black.py b/black.py index 537ba59..587d9b3 100644 --- a/black.py +++ b/black.py @@ -2325,7 +2325,7 @@ def dump_to_file(*output: str) -> str: import tempfile with tempfile.NamedTemporaryFile( - mode="w", prefix="blk_", suffix=".log", delete=False + mode="w", prefix="blk_", suffix=".log", delete=False, encoding="utf8" ) as f: for lines in output: f.write(lines) diff --git a/tests/test_black.py b/tests/test_black.py index f71f9b3..6e6aad8 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -150,7 +150,7 @@ class BlackTestCase(unittest.TestCase): tmp_file = Path(black.dump_to_file(source)) try: self.assertTrue(ff(tmp_file, write_back=black.WriteBack.YES)) - with open(tmp_file) as f: + with open(tmp_file, encoding="utf8") as f: actual = f.read() finally: os.unlink(tmp_file)