@@ -109,13 +109,18 @@ def validate_float(s):
109109
110110
111111def validate_float_or_None (s ):
112- """convert s to float or raise"""
113- if s is None :
112+ """convert s to float, None or raise"""
113+ # values directly from the rc file can only be strings,
114+ # so we need to recognize the string "None" and convert
115+ # it into the object. We will be case-sensitive here to
116+ # avoid confusion between string values of 'none', which
117+ # can be a valid string value for some other parameters.
118+ if s is None or s == 'None' :
114119 return None
115120 try :
116121 return float (s )
117122 except ValueError :
118- raise ValueError ('Could not convert "%s" to float' % s )
123+ raise ValueError ('Could not convert "%s" to float or None ' % s )
119124
120125def validate_dpi (s ):
121126 """confirm s is string 'figure' or convert s to float or raise"""
@@ -476,6 +481,10 @@ def validate_bbox(s):
476481 if s == 'standard' :
477482 return None
478483 raise ValueError ("bbox should be 'tight' or 'standard'" )
484+ elif s is not None :
485+ # Backwards compatibility. None is equivalent to 'standard'.
486+ raise ValueError ("bbox should be 'tight' or 'standard'" )
487+ return s
479488
480489def validate_sketch (s ):
481490 if isinstance (s , six .string_types ):
@@ -790,7 +799,7 @@ def __call__(self, s):
790799 # value checked by backend at runtime
791800 'savefig.format' : ['png' , update_savefig_format ],
792801 # options are 'tight', or 'standard'. 'standard' validates to None.
793- 'savefig.bbox' : [None , validate_bbox ],
802+ 'savefig.bbox' : ['standard' , validate_bbox ],
794803 'savefig.pad_inches' : [0.1 , validate_float ],
795804 # default directory in savefig dialog box
796805 'savefig.directory' : ['~' , six .text_type ],
0 commit comments