Skip to content

Commit c7e5bb7

Browse files
committed
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.
1 parent 8ddeea1 commit c7e5bb7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,12 @@ def wrapper(*args, **kwargs):
16011601
r'^savefig|print_[A-Za-z0-9]+|_no_output_draw$'
16021602
)
16031603
seen_print_figure = False
1604-
for frame, line in traceback.walk_stack(None):
1604+
if sys.version_info < (3, 11):
1605+
current_frame = None
1606+
else:
1607+
import inspect
1608+
current_frame = inspect.currentframe()
1609+
for frame, line in traceback.walk_stack(current_frame):
16051610
if frame is None:
16061611
# when called in embedded context may hit frame is None.
16071612
break

0 commit comments

Comments
 (0)