@@ -146,11 +146,12 @@ def _to_rgba_no_colorcycle(c, alpha=None):
146
146
If `alpha` is not `None`, it forces the alpha value.
147
147
"""
148
148
orig_c = c
149
- if isinstance (c , six .string_types ) and c .lower () == "none" :
150
- return (0. , 0. , 0. , 0. )
151
149
if isinstance (c , six .string_types ):
150
+ if c .lower () == "none" :
151
+ return (0. , 0. , 0. , 0. )
152
152
# Named color.
153
153
try :
154
+ # This may turn c into a non-string, so we check again below.
154
155
c = _colors_full_map [c .lower ()]
155
156
except KeyError :
156
157
pass
@@ -161,7 +162,6 @@ def _to_rgba_no_colorcycle(c, alpha=None):
161
162
return (tuple (int (n , 16 ) / 255
162
163
for n in [c [1 :3 ], c [3 :5 ], c [5 :7 ]])
163
164
+ (alpha if alpha is not None else 1. ,))
164
- if isinstance (c , six .string_types ):
165
165
# hex color with alpha.
166
166
match = re .match (r"\A#[a-fA-F0-9]{8}\Z" , c )
167
167
if match :
@@ -170,10 +170,9 @@ def _to_rgba_no_colorcycle(c, alpha=None):
170
170
if alpha is not None :
171
171
color [- 1 ] = alpha
172
172
return tuple (color )
173
- if isinstance (c , six .string_types ):
174
173
# string gray.
175
174
try :
176
- return (float (c ),) * 3 + (1. ,)
175
+ return (float (c ),) * 3 + (alpha if alpha is not None else 1. ,)
177
176
except ValueError :
178
177
pass
179
178
raise ValueError ("Invalid RGBA argument: {!r}" .format (orig_c ))
0 commit comments