Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Made docbuild errors easier to debug + fixed error from changed exception class (#3229)

Benjamin Hacklcbf6726f8997
diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py
index fe43764ed..e4df6dc53 100644
--- a/manim/utils/docbuild/manim_directive.py
+++ b/manim/utils/docbuild/manim_directive.py
@@ -272,10 +272,13 @@ class ManimDirective(Directive):
f"{clsname}().render()",
]
- with tempconfig(example_config):
- run_time = timeit(lambda: exec("\n".join(code), globals()), number=1)
- video_dir = config.get_dir("video_dir")
- images_dir = config.get_dir("images_dir")
+ try:
+ with tempconfig(example_config):
+ run_time = timeit(lambda: exec("\n".join(code), globals()), number=1)
+ video_dir = config.get_dir("video_dir")
+ images_dir = config.get_dir("images_dir")
+ except Exception as e:
+ raise RuntimeError(f"Error while rendering example {clsname}") from e
_write_rendering_stats(
clsname,
diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py
index 60e4422f1..f8a259b06 100644
--- a/manim/utils/hashing.py
+++ b/manim/utils/hashing.py
@@ -207,7 +207,7 @@ class _CustomEncoder(json.JSONEncoder):
del cvardict[i]
try:
code = inspect.getsource(obj)
- except OSError:
+ except (OSError, TypeError):
# This happens when rendering videos included in the documentation
# within doctests and should be replaced by a solution avoiding
# hash collision (due to the same, empty, code strings) at some point.