@@ -874,22 +874,22 @@ def _rc_params_in_file(fname, fail_on_error=False):
874
874
rc_temp = {}
875
875
with _open_file_or_url (fname ) as fd :
876
876
try :
877
- for cnt , line in enumerate (fd , 1 ):
877
+ for line_no , line in enumerate (fd , 1 ):
878
878
strippedline = line .split ('#' , 1 )[0 ].strip ()
879
879
if not strippedline :
880
880
continue
881
881
tup = strippedline .split (':' , 1 )
882
8
8000
82
if len (tup ) != 2 :
883
- error_details = _error_details_fmt % (cnt , line , fname )
883
+ error_details = _error_details_fmt % (line_no , line , fname )
884
884
_log .warning ('Illegal %s' , error_details )
885
885
continue
886
886
key , val = tup
887
887
key = key .strip ()
888
888
val = val .strip ()
889
889
if key in rc_temp :
890
890
_log .warning ('Duplicate key in file %r line #%d.' ,
891
- fname , cnt )
892
- rc_temp [key ] = (val , line , cnt )
891
+ fname , line_no )
892
+ rc_temp [key ] = (val , line , line_no )
893
893
except UnicodeDecodeError :
894
894
_log .warning ('Cannot decode configuration file %s with encoding '
895
895
'%s, check LANG and LC_* variables.' ,
@@ -900,15 +900,15 @@ def _rc_params_in_file(fname, fail_on_error=False):
900
900
901
901
config = RcParams ()
902
902
903
- for key , (val , line , cnt ) in rc_temp .items ():
903
+ for key , (val , line , line_no ) in rc_temp .items ():
904
904
if key in defaultParams :
905
905
if fail_on_error :
906
906
config [key ] = val # try to convert to proper type or raise
907
907
else :
908
908
try :
909
909
config [key ] = val # try to convert to proper type or skip
910
910
except Exception as msg :
911
- error_details = _error_details_fmt % (cnt , line , fname )
911
+ error_details = _error_details_fmt % (line_no , line , fname )
912
912
_log .warning ('Bad val %r on %s\n \t %s' ,
913
913
val , error_details , msg )
914
914
elif key in _deprecated_ignore_map :
@@ -917,14 +917,13 @@ def _rc_params_in_file(fname, fail_on_error=False):
917
917
version , name = key , alternative = alt_key ,
918
918
addendum = "Please update your matplotlibrc." )
919
919
else :
920
- print ("""
921
- Bad key "%s" on line %d in
922
- %s.
920
+ version = 'master' if '.post' in __version__ else f'v{ __version__ } '
921
+ print (f"""
922
+ Bad key "{ key } " on line { line_no } in
923
+ { fname } .
923
924
You probably need to get an updated matplotlibrc file from
924
- http://github.com/matplotlib/matplotlib/blob/master/matplotlibrc.template
925
- or from the matplotlib source distribution""" % (key , cnt , fname ),
926
- file = sys .stderr )
927
-
925
+ https://github.com/matplotlib/matplotlib/blob/{ version } /matplotlibrc.template
926
+ or from the matplotlib source distribution""" , file = sys .stderr )
928
927
return config
929
928
930
929
0 commit comments