Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed certain unicode characters in users' paths causing issues on Windows (#1547)

friedkeenan8e1407e7fd5c
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index 5c67708cb..5420c44f2 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -560,7 +560,7 @@ class SceneFileWriter:
f"Partial movie files to combine ({len(input_files)} files): %(p)s",
{"p": input_files[:5]},
)
- with open(file_list, "w") as fp:
+ with open(file_list, "w", encoding="utf-8") as fp:
fp.write("# This file is used internally by FFMPEG.\n")
for pf_path in input_files:
if os.name == "nt":
diff --git a/tests/test_scene_rendering/test_file_writer.py b/tests/test_scene_rendering/test_file_writer.py
new file mode 100644
index 000000000..f7ead0d48
--- /dev/null
+++ b/tests/test_scene_rendering/test_file_writer.py
@@ -0,0 +1,26 @@
+import sys
+
+import pytest
+
+from manim.utils.commands import capture
+
+
+def test_unicode_partial_movie(tmpdir, simple_scenes_path):
+ # Characters that failed for a user on Windows
+ # due to its weird default encoding.
+ unicode_str = "三角函数"
+
+ scene_name = "SquareToCircle"
+ command = [
+ sys.executable,
+ "-m",
+ "manim",
+ "--media_dir",
+ str(tmpdir / unicode_str),
+ simple_scenes_path,
+ scene_name,
+ ]
+
+ _, err, exit_code = capture(command)
+ assert exit_code == 0, err