8000 In case fallback to Agg fails, let the exception propagate out. · matplotlib/matplotlib@6c94fc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c94fc8

Browse files
committed
In case fallback to Agg fails, let the exception propagate out.
... as there's likely something very wrong with the user's install.
1 parent c36be6a commit 6c94fc8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/pyplot.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,21 @@ def switch_backend(newbackend):
198198
# Don't try to fallback on the cairo-based backends as they each have
199199
# an additional dependency (pycairo) over the agg-based backend, and
200200
# are of worse quality.
201-
for candidate in ["macosx", "qt5agg", "qt4agg", "gtk3agg", "tkagg",
202-
"wxagg", "agg"]:
201+
for candidate in [
202+
"macosx", "qt5agg", "qt4agg", "gtk3agg", "tkagg", "wxagg"]:
203203
try:
204204
switch_backend(candidate)
205205
except ImportError:
206206
continue
207207
else:
208208
rcParamsOrig['backend'] = candidate
209209
return
210+
else:
211+
# Switching to Agg should always succeed; if it doesn't, let the
212+
# exception propagate out.
213+
switch_backend("agg")
214+
rcParamsOrig["backend"] = "agg"
215+
return
210216

211217
backend_name = (
212218
newbackend[9:] if newbackend.startswith("module://")

0 commit comments

Comments
 (0)
0