@@ -175,17 +175,17 @@ def validate_string_or_None(s):
175
175
raise ValueError ('Could not convert "%s" to string' % s )
176
176
177
177
178
- def _validate_stringlist_or_string (s ):
179
- """convert s to string or raise"""
178
+ def _validate_tex_preamble (s ):
180
179
if s is None or s == 'None' :
181
180
return ""
182
181
try :
183
182
if isinstance (s , str ):
184
183
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 :
189
189
raise ValueError ('Could not convert "%s" to string' % s )
190
190
191
191
@@ -412,7 +412,7 @@ def validate_color(s):
412
412
413
413
414
414
def validate_string (s ):
415
- if isinstance (s , ( str , str ) ):
415
+ if isinstance (s , str ):
416
416
# Always leave str as str and unicode as unicode
417
417
return s
418
418
else :
@@ -1129,7 +1129,7 @@ def _validate_linestyle(ls):
1129
1129
'text.color' : ['black' , validate_color ],
1130
1130
'text.usetex' : [False , validate_bool ],
1131
1131
'text.latex.unicode' : [True , validate_bool ],
1132
- 'text.latex.preamble' : ['' , _validate_stringlist_or_string ],
1132
+ 'text.latex.preamble' : ['' , _validate_tex_preamble ],
1133
1133
'text.latex.preview' : [False , validate_bool ],
1134
1134
'text.dvipnghack' : [None , validate_bool_maybe_none ],
1135
1135
'text.hinting' : ['auto' , validate_hinting ],
@@ -1405,7 +1405,7 @@ def _validate_linestyle(ls):
1405
1405
# use matplotlib rc settings for font configuration
1406
1406
'pgf.rcfonts' : [True , validate_bool ],
1407
1407
# provide a custom preamble for the latex process
1408
- 'pgf.preamble' : ['' , _validate_stringlist_or_string ],
1408
+ 'pgf.preamble' : ['' , _validate_tex_preamble ],
1409
1409
1410
1410
# write raster image data directly into the svg file
1411
1411
'svg.image_inline' : [True , validate_bool ],
0 commit comments