Fix UnboundLocalError in _border and document rgba() color format by veeceey · Pull Request #9426 · python-pillow/Pillow

Fair point on splitting, noted for next time.

On the motivation -- I was looking at the ImageOps.expand code and noticed the border validation raises ValueError for negative values, but if you pass something like a 3-tuple (which is not a valid border spec), the unpacking just silently fails and border stays partially unpacked, leaving bottom unbound. Then the subsequent code hits an UnboundLocalError, which is confusing because the real issue is the invalid input. So yes, I did trace through it manually -- the UnboundLocalError masks the actual problem.

Will apply the test simplification you suggested.