mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
rrggbb_to_triplet(): When color doesn't start with `#' raise a
BadColor exception.
This commit is contained in:
parent
5b67839ca3
commit
b7b1cf0088
1 changed files with 2 additions and 1 deletions
|
@ -177,7 +177,8 @@ def rrggbb_to_triplet(color, atoi=string.atoi):
|
||||||
"""Converts a #rrggbb color to the tuple (red, green, blue)."""
|
"""Converts a #rrggbb color to the tuple (red, green, blue)."""
|
||||||
rgbtuple = _namedict.get(color)
|
rgbtuple = _namedict.get(color)
|
||||||
if rgbtuple is None:
|
if rgbtuple is None:
|
||||||
assert color[0] == '#'
|
if color[0] <> '#':
|
||||||
|
raise BadColor(color)
|
||||||
red = color[1:3]
|
red = color[1:3]
|
||||||
green = color[3:5]
|
green = color[3:5]
|
||||||
blue = color[5:7]
|
blue = color[5:7]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue