From c7e5bb749af29b5d405115e3a984eec85bac4ef3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 21 Nov 2021 19:01:57 -0500 Subject: [PATCH 1/2] MNT: make print_figure kwarg wrapper support py311 Do not fully understand what changed, but without this change `walk_stack` would start 2 frames higher (in the test module, not in backend_bases) which would mean we never saw the frame with `print_figure` and hence was getting warnings which we converted to failures on a vast majority of the tests. I suspect that this is related to the fast-Python work and avoiding making unneeded structures during the calls, but chased that theory down yet. Discovered on a commit between py311a2 and py311a3. --- lib/matplotlib/backend_bases.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7dbca2e64b60..059cc61aae55 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 From 74b45ffcba5a98fc083cd9a8609eb70699b99519 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 21 Nov 2021 19:07:34 -0500 Subject: [PATCH 2/2] API: make promise of removal date We should have pulled this out in mpl3.5 --- lib/matplotlib/backend_bases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 059cc61aae55..e3d1b3efbd83 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1640,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 '