Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91906bc

Browse files
committed
Handle bytes and unicode
1 parent 140d0ab commit 91906bc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/matplotlib/colors.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,14 @@ def is_color_like(c):
224224
# Special-case the N-th color cycle syntax, because it's parsing
225225
# needs to be deferred. We may be reading a value from rcParams
226226
# here before the color_cycle rcParam has been parsed.
227-
match = re.match('^\[[0-9]\]$', c)
228-
if match is not None:
229-
return True
227+
if isinstance(c, bytes):
228+
match = re.match(b'^\[[0-9]\]$', c)
229+
if match is not None:
230+
return True
231+
elif isinstance(c, six.text_type):
232+
match = re.match('^\[[0-9]\]$', c)
233+
if match is not None:
234+
return True
230235

231236
try:
232237
colorConverter.to_rgb(c)

0 commit comments

Comments
 (0)