@@ -109,13 +109,18 @@ def validate_float(s):
109
109
110
110
111
111
def 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' :
114
119
return None
115
120
try :
116
121
return float (s )
117
122
except ValueError :
118
- raise ValueError ('Could not convert "%s" to float' % s )
123
+ raise ValueError ('Could not convert "%s" to float or None ' % s )
119
124
120
125
def validate_dpi (s ):
121
126
"""confirm s is string 'figure' or convert s to float or raise"""
@@ -476,6 +481,10 @@ def validate_bbox(s):
476
481
if s == 'standard' :
477
482
return None
478
483
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
479
488
480
489
def validate_sketch (s ):
481
490
if isinstance (s , six .string_types ):
@@ -790,7 +799,7 @@ def __call__(self, s):
790
799
# value checked by backend at runtime
791
800
'savefig.format' : ['png' , update_savefig_format ],
792
801
# options are 'tight', or 'standard'. 'standard' validates to None.
793
- 'savefig.bbox' : [None , validate_bbox ],
802
+ 'savefig.bbox' : ['standard' , validate_bbox ],
794
803
'savefig.pad_inches' : [0.1 , validate_float ],
795
804
# default directory in savefig dialog box
796
805
'savefig.directory' : ['~' , six .text_type ],
0 commit comments