Skip to content

Commit f3bfd21

Browse files
Merge pull request #4022 from rxxg/bugfix-3898
Handle Unicode characters on systems where utf-8 is not default
2 parents dfef73e + 1f86ff0 commit f3bfd21

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/python/plotly/plotly/io/_html.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ def write_html(
533533

534534
# Write HTML string
535535
if path is not None:
536-
path.write_text(html_str)
536+
# To use a different file encoding, pass a file descriptor
537+
path.write_text(html_str, "utf-8")
537538
else:
538539
file.write(html_str)
539540

packages/python/plotly/plotly/tests/test_io/test_pathlib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_write_html():
4040
mock_pathlib_path = Mock(spec=Path)
4141
pio.write_html(fig, mock_pathlib_path)
4242
mock_pathlib_path.write_text.assert_called_once()
43-
(pl_html,) = mock_pathlib_path.write_text.call_args[0]
43+
pl_html = mock_pathlib_path.write_text.call_args[0][0]
4444
assert replace_div_id(html) == replace_div_id(pl_html)
4545

4646
# Test pio.write_html with a mock file descriptor

0 commit comments

Comments
 (0)