Skip to content

Commit ab1e5c2

Browse files
committed
Raise TypeError on invalid RGBA type
1 parent 11b69eb commit ab1e5c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sdl2/ext/color.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def __init__(self, r=255, g=255, b=255, a=255):
5555
def _verify_rgba_value(self, val):
5656
"""Verifies that the input is a valid uint8 RGBA value."""
5757
e = "All RGBA color values must be integers between 0 and 255 (got {0})"
58-
if val < 0 or val > 255 or int(val) != val:
58+
try:
59+
float(val)
60+
except (ValueError, TypeError):
61+
raise TypeError(e.format(val))
62+
if int(val) != val or val < 0 or val > 255:
5963
raise ValueError(e.format(val))
6064

6165
def __repr__(self):

0 commit comments

Comments
 (0)