8000 Backport PR #25240 on branch v3.7.x (Avoid calling vars() on arbitrary third-party manager_class.) by meeseeksmachine · Pull Request #25246 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def _tight_layout(self):
self._figure.tight_layout()
for attr, spinbox in self._spinboxes.items():
spinbox.blockSignals(True)
spinbox.setValue(vars(self._figure.subplotpars)[attr])
spinbox.setValue(getattr(self._figure.subplotpars, attr))
spinbox.blockSignals(False)
self._figure.canvas.draw_idle()

Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/pyplot.py
8D11
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,12 @@ def draw_if_interactive():
# show is already present, as the latter may be here for backcompat.
manager_class = getattr(getattr(backend_mod, "FigureCanvas", None),
"manager_class", None)
# We can't compare directly manager_class.pyplot_show and FMB.pyplot_show
# because pyplot_show is a classmethod so the above constructs are bound
# classmethods, & thus always different (being bound to different classes).
manager_pyplot_show = vars(manager_class).get("pyplot_show")
base_pyplot_show = vars(FigureManagerBase).get("pyplot_show")
# We can't compare directly manager_class.pyplot_show and FMB.pyplot_show because
# pyplot_show is a classmethod so the above constructs are bound classmethods, and
# thus always different (being bound to different classes). We also have to use
# getattr_static instead of vars as manager_class could have no __dict__.
manager_pyplot_show = inspect.getattr_static(manager_class, "pyplot_show", None)
base_pyplot_show = inspect.getattr_static(FigureManagerBase, "pyplot_show", None)
if (show is None
or (manager_pyplot_show is not None
and manager_pyplot_show != base_pyplot_show)):
Expand Down
0