132132import subprocess
133133import tempfile
134134import urllib .request
135- import warnings
136135
137136# cbook must import matplotlib only within function
138137# definitions, so it is safe to import from it here.
@@ -760,8 +759,7 @@ def __str__(self):
760759
761760 def __iter__ (self ):
762761 """Yield sorted list of keys."""
763- with warnings .catch_warnings ():
764- warnings .simplefilter ('ignore' , MatplotlibDeprecationWarning )
762+ with cbook ._suppress_matplotlib_deprecation_warning ():
765763 yield from sorted (dict .__iter__ (self ))
766764
767765 def __len__ (self ):
@@ -917,8 +915,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
917915 return config_from_file
918916
919917 iter_params = defaultParams .items ()
920- with warnings .catch_warnings ():
921- warnings .simplefilter ("ignore" , MatplotlibDeprecationWarning )
918+ with cbook ._suppress_matplotlib_deprecation_warning ():
922919 config = RcParams ([(key , default ) for key , (default , _ ) in iter_params
923920 if key not in _all_deprecated ])
924921 config .update (config_from_file )
@@ -958,8 +955,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
958955 rcParams ['examples.directory' ] = _fullpath
959956
960957
961- with warnings .catch_warnings ():
962- warnings .simplefilter ("ignore" , MatplotlibDeprecationWarning )
958+ with cbook ._suppress_matplotlib_deprecation_warning ():
963959 rcParamsOrig = RcParams (rcParams .copy ())
964960 rcParamsDefault = RcParams ([(key , default ) for key , (default , converter ) in
965961 defaultParams .items ()
@@ -1062,8 +1058,7 @@ def rcdefaults():
10621058 """
10631059 # Deprecation warnings were already handled when creating rcParamsDefault,
10641060 # no need to reemit them here.
1065- with warnings .catch_warnings ():
1066- warnings .simplefilter ("ignore" , mplDeprecation )
1061+ with cbook ._suppress_matplotlib_deprecation_warning ():
10671062 from .style .core import STYLE_BLACKLIST
10681063 rcParams .clear ()
10691064 rcParams .update ({k : v for k , v in rcParamsDefault .items ()
@@ -1079,8 +1074,7 @@ def rc_file_defaults():
10791074 """
10801075 # Deprecation warnings were already handled when creating rcParamsOrig, no
10811076 # need to reemit them here.
1082- with warnings .catch_warnings ():
1083- warnings .simplefilter ("ignore" , mplDeprecation )
1077+ with cbook ._suppress_matplotlib_deprecation_warning ():
10841078 from .style .core import STYLE_BLACKLIST
10851079 rcParams .update ({k : rcParamsOrig [k ] for k in rcParamsOrig
10861080 if k not in STYLE_BLACKLIST })
@@ -1106,8 +1100,7 @@ def rc_file(fname, *, use_default_template=True):
11061100 """
11071101 # Deprecation warnings were already handled in rc_params_from_file, no need
11081102 # to reemit them here.
1109- with warnings .catch_warnings ():
1110- warnings .simplefilter ("ignore" , mplDeprecation )
1103+ with cbook ._suppress_matplotlib_deprecation_warning ():
11111104 from .style .core import STYLE_BLACKLIST
11121105 rc_from_file = rc_params_from_file (
11131106 fname , use_default_template = use_default_template )
0 commit comments