fix AttributeError on CompositeVideoClip with non-composite mask#2554
Open
Mr-Neutr0n wants to merge 1 commit intoZulko:masterfrom
Open
fix AttributeError on CompositeVideoClip with non-composite mask#2554Mr-Neutr0n wants to merge 1 commit intoZulko:masterfrom
Mr-Neutr0n wants to merge 1 commit intoZulko:masterfrom
Conversation
CompositeVideoClip.frame_function accesses self.mask.precomputed without checking if the mask actually has this attribute. The precomputed dict is only set on CompositeVideoClip instances where is_mask=True and memoize_mask=True, so using a regular VideoClip as a mask (e.g. via to_mask()) causes an AttributeError. Added a hasattr guard before accessing self.mask.precomputed. Fixes Zulko#2514
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When you set a mask on a
CompositeVideoClipthat isn't itself aCompositeVideoClip(e.g. created viato_mask()), callingframe_functioncrashes withAttributeError: 'CompositeVideoClip' object has no attribute 'precomputed'.The
precomputeddict only gets created onCompositeVideoClipinstances whereis_mask=Trueandmemoize_mask=True(in__init__). Butframe_functionunconditionally accessesself.mask.precomputedwhenself.maskandself.memoize_maskare truthy, without checking whether the mask object actually has that attribute.The fix just adds a
hasattrguard so we only try to memoize when the mask supports it.Fixes #2514