Commit 8e7848c6 authored by Zsolt Dollenstein's avatar Zsolt Dollenstein Committed by Łukasz Langa
Browse files

Open temporary files with utf-8 encoding (#126)

This is not the default on Windows.
parent c071af76
Loading
Loading
Loading
Loading
+1 −1
Changes for black.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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)
+1 −1
Changes for tests/test_black.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ def test_expression_ff(self) -> None:
        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)