Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7671962

Browse filesBrowse files
committed
Avoid triggering backend resolution during qt initial import.
1 parent 0e87f48 commit 7671962
Copy full SHA for 7671962

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
QT_API = QT_API_PYSIDE
4343
# Otherwise, check the QT_API environment variable (from Enthought). This can
4444
# 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"]:
4749
if QT_API_ENV in ["pyqt5", "pyside2"]:
4850
QT_API = _ETS[QT_API_ENV]
4951
else:
5052
QT_API = None
51-
elif mpl.rcParams["backend"] in ["Qt4Agg", "Qt4Cairo"]:
53+
elif dict.__getitem__(mpl.rcParams, "backend") in ["Qt4Agg", "Qt4Cairo"]:
5254
if QT_API_ENV in ["pyqt4", "pyside"]:
5355
QT_API = _ETS[QT_API_ENV]
5456
else:
@@ -150,8 +152,8 @@ def is_pyqt5():
150152
_setup_pyqt5()
151153
elif QT_API in [QT_API_PYQTv2, QT_API_PYSIDE, QT_API_PYQT]:
152154
_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":
155157
_candidates = [(_setup_pyqt4, QT_API_PYQTv2),
156158
(_setup_pyqt4, QT_API_PYSIDE),
157159
(_setup_pyqt4, QT_API_PYQT),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.