A community-maintained Python framework for creating mathematical animations.
fix: infinite recursion caused by accessing color of a highlighted Ta… (#4435)
BHearron382c0b49be9f67
diff --git a/manim/mobject/geometry/shape_matchers.py b/manim/mobject/geometry/shape_matchers.pyindex ae2a70db4..59abba646 100644--- a/manim/mobject/geometry/shape_matchers.py+++ b/manim/mobject/geometry/shape_matchers.py@@ -20,7 +20,7 @@ from manim.mobject.geometry.polygram import RoundedRectanglefrom manim.mobject.mobject import Mobjectfrom manim.mobject.opengl.opengl_mobject import OpenGLMobjectfrom manim.mobject.types.vectorized_mobject import VGroup-from manim.utils.color import BLACK, RED, YELLOW, ManimColor, ParsableManimColor+from manim.utils.color import BLACK, RED, YELLOW, ParsableManimColorclass SurroundingRectangle(RoundedRectangle):@@ -149,12 +149,6 @@ class BackgroundRectangle(SurroundingRectangle):)return self- def get_fill_color(self) -> ManimColor:- # The type of the color property is set to Any using the property decorator- # vectorized_mobject.py#L571- temp_color: ManimColor = self.color- return temp_color-class Cross(VGroup):"""Creates a cross.diff --git a/tests/module/mobject/geometry/test_unit_geometry.py b/tests/module/mobject/geometry/test_unit_geometry.pyindex 2de94a3b0..71de829d0 100644--- a/tests/module/mobject/geometry/test_unit_geometry.py+++ b/tests/module/mobject/geometry/test_unit_geometry.py@@ -7,6 +7,7 @@ import numpy as npfrom manim import (DEGREES,DOWN,+ GREEN,LEFT,ORIGIN,RIGHT,@@ -152,6 +153,18 @@ def test_BackgroundRectangle(manim_caplog):)+def test_BackgroundRectangle_color_access():+ """Test that BackgroundRectangle color access works correctly.++ Regression test for https://github.com/ManimCommunity/manim/issues/4419+ """+ square = Square()+ bg_rect = BackgroundRectangle(square, color=GREEN)++ # Should not cause infinite recursion+ assert bg_rect.color == GREEN++def test_Square_side_length_reflets_correct_width_and_height():sq = Square(side_length=1).scale(3)assert sq.side_length == 3diff --git a/tests/module/mobject/test_table.py b/tests/module/mobject/test_table.pynew file mode 100644index 000000000..739f7aaaf--- /dev/null+++ b/tests/module/mobject/test_table.py@@ -0,0 +1,19 @@+"""Tests for Table and related mobjects."""++from __future__ import annotations++from manim import Table+from manim.utils.color import GREEN+++def test_highlighted_cell_color_access():+ """Test that accessing the color of a highlighted cell doesn't cause infinite recursion.++ Regression test for https://github.com/ManimCommunity/manim/issues/4419+ """+ table = Table([["This", "is a"], ["simple", "table"]])+ rect = table.get_highlighted_cell((1, 1), color=GREEN)++ # Should not raise RecursionError+ color = rect.color+ assert color == GREEN