@@ -175,17 +175,17 @@ def validate_string_or_None(s):
175175 raise ValueError ('Could not convert "%s" to string' % s )
176176
177177
178- def _validate_stringlist_or_string (s ):
179- """convert s to string or raise"""
178+ def _validate_tex_preamble (s ):
180179 if s is None or s == 'None' :
181180 return ""
182181 try :
183182 if isinstance (s , str ):
184183 return s
185- if isinstance (s , Iterable ):
186- return '\n ' .join ([str (i ) for i in s ])
187- raise ValueError ()
188- except ValueError :
184+ elif isinstance (s , Iterable ):
185+ return '\n ' .join (s )
186+ else :
187+ raise TypeError
188+ except TypeError :
189189 raise ValueError ('Could not convert "%s" to string' % s )
190190
191191
@@ -412,7 +412,7 @@ def validate_color(s):
412412
413413
414414def validate_string (s ):
415- if isinstance (s , ( str , str ) ):
415+ if isinstance (s , str ):
416416 # Always leave str as str and unicode as unicode
417417 return s
418418 else :
@@ -1129,7 +1129,7 @@ def _validate_linestyle(ls):
11291129 'text.color' : ['black' , validate_color ],
11301130 'text.usetex' : [False , validate_bool ],
11311131 'text.latex.unicode' : [True , validate_bool ],
1132- 'text.latex.preamble' : ['' , _validate_stringlist_or_string ],
1132+ 'text.latex.preamble' : ['' , _validate_tex_preamble ],
11331133 'text.latex.preview' : [False , validate_bool ],
11341134 'text.dvipnghack' : [None , validate_bool_maybe_none ],
11351135 'text.hinting' : ['auto' , validate_hinting ],
@@ -1405,7 +1405,7 @@ def _validate_linestyle(ls):
14051405 # use matplotlib rc settings for font configuration
14061406 'pgf.rcfonts' : [True , validate_bool ],
14071407 # provide a custom preamble for the latex process
1408- 'pgf.preamble' : ['' , _validate_stringlist_or_string ],
1408+ 'pgf.preamble' : ['' , _validate_tex_preamble ],
14091409
14101410 # write raster image data directly into the svg file
14111411 'svg.image_inline' : [True , validate_bool ],
0 commit comments