Raise ValueError if ImageOps border has unsupported format - #9426
Merged
radarhere merged 2 commits intoApr 24, 2026
Conversation
radarhere
reviewed
Feb 10, 2026
Summary
Fix bug in
ImageOps._border(): When given a tuple with a length other than 2 or 4 (e.g. a 1-tuple or 3-tuple), the function raised an unhelpfulUnboundLocalErrorbecause theleft,top,right,bottomvariables were never assigned. This now raises a clearValueErrorwith a descriptive message instead.Document
rgba()color format inImageColor: Thergba(red, green, blue, alpha)color string format has been supported in code and tested for a long time, but was missing from theImageColordocumentation. This adds it to the list of supported color string formats.Test plan
test_expand_invalid_borderthat verifiesValueErroris raised for 1-tuple, 3-tuple, and 5-tuple border valuesUnboundLocalError