diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7dbca2e64b60..e3d1b3efbd83 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1601,7 +1601,12 @@ def wrapper(*args, **kwargs): r'^savefig|print_[A-Za-z0-9]+|_no_output_draw$' ) seen_print_figure = False - for frame, line in traceback.walk_stack(None): + if sys.version_info < (3, 11): + current_frame = None + else: + import inspect + current_frame = inspect.currentframe() + for frame, line in traceback.walk_stack(current_frame): if frame is None: # when called in embedded context may hit frame is None. break @@ -1635,7 +1640,7 @@ def wrapper(*args, **kwargs): if arg in accepted_kwargs: continue _api.warn_deprecated( - '3.3', name=name, + '3.3', name=name, removal='3.6', message='%(name)s() got unexpected keyword argument "' + arg + '" which is no longer supported as of ' '%(since)s and will become an error '