@@ -771,14 +771,14 @@ def matplotlib_fname():
771771
772772
773773_deprecated_map = {
774- 'text.fontstyle' : 'font.style' ,
775- 'text.fontangle' : 'font.style' ,
776- 'text.fontvariant' : 'font.variant' ,
777- 'text.fontweight' : 'font.weight' ,
778- 'text.fontsize' : 'font.size' ,
779- 'tick.size' : 'tick.major.size' ,
780- 'svg.embed_char_paths' : 'svg.fonttype' ,
781- 'savefig.extension' : 'savefig.format'
774+ 'text.fontstyle' : ( 'font.style' , lambda x : x ) ,
775+ 'text.fontangle' : ( 'font.style' , lambda x : x ) ,
776+ 'text.fontvariant' : ( 'font.variant' , lambda x : x ) ,
777+ 'text.fontweight' : ( 'font.weight' , lambda x : x ) ,
778+ 'text.fontsize' : ( 'font.size' , lambda x : x ) ,
779+ 'tick.size' : ( 'tick.major.size' , lambda x : x ) ,
780+ 'svg.embed_char_paths' : ( 'svg.fonttype' , lambda x : "path" if x else "none" ) ,
781+ 'savefig.extension' : ( 'savefig.format' , lambda x : x ),
782782 }
783783
784784_deprecated_ignore_map = {
@@ -802,24 +802,28 @@ class RcParams(dict):
802802 def __setitem__ (self , key , val ):
803803 try :
804804 if key in _deprecated_map :
805- alt = _deprecated_map [key ]
806- warnings .warn (self .msg_depr % (key , alt ))
807- key = alt
805+ alt_key , alt_val = _deprecated_map [key ]
806+ warnings .warn (self .msg_depr % (key , alt_key ))
807+ key = alt_key
808+ val = alt_val (val )
808809 elif key in _deprecated_ignore_map :
809810 alt = _deprecated_ignore_map [key ]
810811 warnings .warn (self .msg_depr_ignore % (key , alt ))
811812 return
812- cval = self .validate [key ](val )
813+ try :
814+ cval = self .validate [key ](val )
815+ except ValueError as ve :
816+ raise ValueError ("Key %s: %s" % (key , str (ve )))
813817 dict .__setitem__ (self , key , cval )
814818 except KeyError :
815819 raise KeyError ('%s is not a valid rc parameter.\
816820 See rcParams.keys() for a list of valid parameters.' % (key ,))
817821
818822 def __getitem__ (self , key ):
819823 if key in _deprecated_map :
820- alt = _deprecated_map [key ]
821- warnings .warn (self .msg_depr % (key , alt ))
822- key = alt
824+ alt_key , alt_val = _deprecated_map [key ]
825+ warnings .warn (self .msg_depr % (key , alt_key ))
826+ key = alt_key
823827 elif key in _deprecated_ignore_map :
824828 alt = _deprecated_ignore_map [key ]
825829 warnings .warn (self .msg_depr_ignore % (key , alt ))
0 commit comments