@@ -63,7 +63,7 @@ def __call__(self, s):
6363 s = s .lower ()
6464 if s in self .valid :
6565 return self .valid [s ]
66- raise ValueError ('Unrecognized %s string "%s" : valid strings are %s'
66+ raise ValueError ('Unrecognized %s string %r : valid strings are %s'
6767 % (self .key , s , list (six .itervalues (self .valid ))))
6868
6969
@@ -889,7 +889,7 @@ def validate_cycler(s):
889889
890890
891891def validate_hist_bins (s ):
892- if isinstance (s , six . string_types ) and s == ' auto' :
892+ if cbook . _str_equal (s , " auto" ) :
893893 return s
894894 try :
895895 return int (s )
@@ -942,25 +942,13 @@ def _validate_linestyle(ls):
942942 A validator for all possible line styles, the named ones *and*
943943 the on-off ink sequences.
944944 """
945- # Look first for a valid named line style, like '--' or 'solid'
946- if isinstance (ls , six .string_types ):
947- try :
948- return _validate_named_linestyle (ls )
949- except (UnicodeDecodeError , KeyError ):
950- # On Python 2, string-like *ls*, like for example
951- # 'solid'.encode('utf-16'), may raise a unicode error.
952- raise ValueError ("the linestyle string {!r} is not a valid "
953- "string." .format (ls ))
954-
955- if isinstance (ls , (bytes , bytearray )):
956- # On Python 2, a string-like *ls* should already have lead to a
957- # successful return or to raising an exception. On Python 3, we have
958- # to manually raise an exception in the case of a byte-like *ls*.
959- # Otherwise, if *ls* is of even-length, it will be passed to the
960- # instance of validate_nseq_float, which will return an absurd on-off
961- # ink sequence...
962- raise ValueError ("linestyle {!r} neither looks like an on-off ink "
963- "sequence nor a valid string." .format (ls ))
945+ # Look first for a valid named line style, like '--' or 'solid' Also
946+ # includes bytes(-arrays) here (they all fail _validate_named_linestyle);
947+ # otherwise, if *ls* is of even-length, it will be passed to the instance
948+ # of validate_nseq_float, which will return an absurd on-off ink
949+ # sequence...
950+ if isinstance (ls , (str , bytes , bytearray )):
951+ return _validate_named_linestyle (ls )
964952
965953 # Look for an on-off ink sequence (in points) *of even length*.
966954 # Offset is set to None.
0 commit comments