Conversation
…loop compare() increments grab_failure_cnt on a failed frame grab, but the counter is only ever assigned in the else branch (set to 0 on a successful grab). The first time video1.grab()/video2.grab() returns False, `grab_failure_cnt += 1` runs before any binding exists, raising UnboundLocalError instead of counting the failure and eventually raising the intended "Grab failed too much" guard. Initialize the counter to 0 alongside `similar` so the failure path works as designed.
…loop compare() increments grab_failure_cnt on a failed frame grab, but the counter is only ever assigned in the else branch (set to 0 on a successful grab). The first time video1.grab()/video2.grab() returns False, `grab_failure_cnt += 1` runs before any binding exists, raising UnboundLocalError instead of counting the failure and eventually raising the intended "Grab failed too much" guard. Initialize the counter to 0 alongside `similar` so the failure path works as designed.
This branch has not been deployed
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.
Problem
compare()in the ffmpeg integration test helper (video_cmp.py) counts consecutive failed frame grabs to bail out of a potential endless loop:grab_failure_cntis only ever assigned in theelsebranch (reset to0after a successful grab). The very first time eithervideo1.grab()orvideo2.grab()returnsFalse,grab_failure_cnt += 1executes before any binding exists, so Python raisesUnboundLocalError: local variable 'grab_failure_cnt' referenced before assignment— masking the real "grab failed" condition the counter was meant to detect.Fix
Initialize
grab_failure_cnt = 0alongsidesimilarbefore the loop, so the failure path counts as designed and the endless-loop guard can trigger.Both identical copies (
ffmpeg_basic/andffmpeg_bypass/) are fixed.🤖 Generated with Claude Code