Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module exec #2308

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Fix module exec #2308

wants to merge 2 commits into from

Conversation

Splines
Copy link
Contributor

@Splines Splines commented Feb 4, 2025

Motivation

Fixes #2307

Proposed changes

  • Manually add the module to sys before executing it
  • I've also renamed insert_embed_line_to_module to insert_embed_line_to_module_and_exec to better reflect that this method is actually executing the user code. Please read over the docstrings again as I think they are outdated. I've added two lines beforehand to briefly describe what the method is actually doing.

Test

from dataclasses import dataclass
from manimlib import *


@dataclass
class Coordinates2D:
    x: float
    y: float


class MyScene(Scene):
    def construct(self):
        print("Hello, world!")

If you call this via

manimgl "./path/to/bug-test-file.py" MyScene -e 13

it should show "Hello, world!", instead of crashing like in #2307.

@Splines Splines marked this pull request as draft February 4, 2025 21:20
@Splines
Copy link
Contributor Author

Splines commented Feb 4, 2025

Unfortunately, it turned out that this is not a way to go since this breaks the reloading mechanism, i.e. during reload you will run into the newly added error message Module name is already used by Manim itself, please use a different name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module exec leads to crash
1 participant