|
42 | 42 | QT_API = QT_API_PYSIDE
|
43 | 43 | # Otherwise, check the QT_API environment variable (from Enthought). This can
|
44 | 44 | # only override the binding, not the backend (in other words, we check that the
|
45 |
| -# requested backend actually matches). |
46 |
| -elif mpl.rcParams["backend"] in ["Qt5Agg", "Qt5Cairo"]: |
| 45 | +# requested backend actually matches). Use dict.__getitem__ to avoid |
| 46 | +# triggering backend resolution (which can result in a partially but |
| 47 | +# incompletely imported backend_qt5). |
| 48 | +elif dict.__getitem__(mpl.rcParams, "backend") in ["Qt5Agg", "Qt5Cairo"]: |
47 | 49 | if QT_API_ENV in ["pyqt5", "pyside2"]:
|
48 | 50 | QT_API = _ETS[QT_API_ENV]
|
49 | 51 | else:
|
50 | 52 | QT_API = None
|
51 |
| -elif mpl.rcParams["backend"] in ["Qt4Agg", "Qt4Cairo"]: |
| 53 | +elif dict.__getitem__(mpl.rcParams, "backend") in ["Qt4Agg", "Qt4Cairo"]: |
52 | 54 | if QT_API_ENV in ["pyqt4", "pyside"]:
|
53 | 55 | QT_API = _ETS[QT_API_ENV]
|
54 | 56 | else:
|
@@ -150,8 +152,8 @@ def is_pyqt5():
|
150 | 152 | _setup_pyqt5()
|
151 | 153 | elif QT_API in [QT_API_PYQTv2, QT_API_PYSIDE, QT_API_PYQT]:
|
152 | 154 | _setup_pyqt4()
|
153 |
| -elif QT_API is None: |
154 |
| - if mpl.rcParams["backend"] == "Qt4Agg": |
| 155 | +elif QT_API is None: # See above re: dict.__getitem__. |
| 156 | + if dict.__getitem__(mpl.rcParams, "backend") == "Qt4Agg": |
155 | 157 | _candidates = [(_setup_pyqt4, QT_API_PYQTv2),
|
156 | 158 | (_setup_pyqt4, QT_API_PYSIDE),
|
157 | 159 | (_setup_pyqt4, QT_API_PYQT),
|
|
0 commit comments