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 a583488

Browse filesBrowse files
committed
FIX: skip gtk backend if gobject but not pygtk is installed
It is possible to install gobject (which provides `gi`) but not pygtk (which provide the `GTK` bindings). This try-except converts the ValueError that gi raises to an ImportError so our machinery works correctly.
1 parent 369618a commit a583488
Copy full SHA for a583488

File tree

Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed

‎lib/matplotlib/backends/_gtk3_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/_gtk3_compat.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040

4141
if gi.__name__ == "pgi" and gi.version_info < (0, 0, 11, 2):
4242
raise ImportError("The GTK3 backends are incompatible with pgi<0.0.11.2")
43-
gi.require_version("Gtk", "3.0")
43+
try:
44+
# :raises ValueError: If module/version is already loaded, already
45+
# required, or unavailable.
46+
gi.require_version("Gtk", "3.0")
47+
except ValueError as e:
48+
# in this case we want to re-raise as ImportError so the
49+
# auto-backend selection logic correctly skips.
50+
raise ImportError from e
51+
4452
globals().update(
4553
{name:
4654
importlib.import_module("{}.repository.{}".format(gi.__name__, name))

0 commit comments

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