Fix: Handle NamedTemporaryFile correctly for Windows #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous implementation of PartialCode could lead to a PermissionError on Windows 11. This was because NamedTemporaryFile by default is created with exclusive access and is deleted immediately upon closing. If Manim's Code class (the superclass of PartialCode) tried to open the file path while the NamedTemporaryFile object still held it open (or if it was reopened incorrectly), it would result in a permission denied error.
This commit modifies PartialCode to:
delete=False.super().__init__.os.remove()aftersuper().__init__has finished, preventing leftover temporary files.This ensures the file path is accessible to the Manim Code constructor on Windows and that temporary files are still cleaned up reliably.
I have tested the creation of intro.py and it works.