@@ -245,6 +245,7 @@ def _is_writable_dir(p):
245
245
246
246
return True
247
247
248
+
248
249
class Verbose :
249
250
"""
250
251
A class to handle reporting. Set the fileo attribute to any file
@@ -808,6 +809,14 @@ def matplotlib_fname():
808
809
_all_deprecated = set (chain (_deprecated_ignore_map ,
809
810
_deprecated_map , _obsolete_set ))
810
811
812
+ _rcparam_warn_str = ("Trying to set {key} to {value} via the {func} "
813
+ "method of RcParams which does not validate cleanly. "
814
+ "This warning will turn into an Exception in 1.5. "
815
+ "If you think {value} should validate correctly for "
816
+ "rcParams[{key}] "
817
+ "please create an issue on github."
818
+ )
819
+
811
820
812
821
class RcParams (dict ):
813
822
@@ -827,7 +836,14 @@ class RcParams(dict):
827
836
# validate values on the way in
828
837
def __init__ (self , * args , ** kwargs ):
829
838
for k , v in six .iteritems (dict (* args , ** kwargs )):
830
- self [k ] = v
839
+ try :
840
+ self [k ] = v
841
+ except (ValueError , RuntimeError ):
842
+ # force the issue
843
+ warnings .warn (_rcparam_warn_str .format (key = repr (k ),
844
+ value = repr (v ),
845
+ func = '__init__' ))
846
+ dict .__setitem__ (self , k , v )
831
847
832
848
def __setitem__ (self , key , val ):
833
849
try :
@@ -866,9 +882,15 @@ def __getitem__(self, key):
866
882
# all of the validation over-ride update to force
867
883
# through __setitem__
868
884
def update (self , * args , ** kwargs ):
869
-
870
885
for k , v in six .iteritems (dict (* args , ** kwargs )):
871
- self [k ] = v
886
+ try :
887
+ self [k ] = v
888
+ except (ValueError , RuntimeError ):
889
+ # force the issue
890
+ warnings .warn (_rcparam_warn_str .format (key = repr (k ),
891
+ value = repr (v ),
892
+ func = 'update' ))
893
+ dict .__setitem__ (self , k , v )
872
894
873
895
def __repr__ (self ):
874
896
import pprint
0 commit comments