[master 1/1] Check for Gtk before importing escape_markup
bcl
installerbot-noreply at redhat.com
Tue Apr 14 00:11:24 UTC 2015
From: "Brian C. Lane" <bcl at redhat.com>
Early errors can cause errors.py to be imported before any of the GUI
are setup. Trying to do a full import triggers various side-effects that
cause it to crash in _isys instead of just using the lambda.
This method for checking for Gtk was lifted from exception.py
---
pyanaconda/errors.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/errors.py b/pyanaconda/errors.py
index 4ca7fb3..00f7523 100644
--- a/pyanaconda/errors.py
+++ b/pyanaconda/errors.py
@@ -27,8 +27,19 @@
# Only run the pango markup escape if the GUI is available
try:
+ from gi.repository import Gtk
+
+ # XXX: Gtk stopped raising RuntimeError if it fails to
+ # initialize. Horay! But will it stay like this? Let's be
+ # cautious and raise the exception on our own to work in both
+ # cases
+ initialized = Gtk.init_check(None)[0]
+ if not initialized:
+ raise RuntimeError()
+
+ # If we don't do the check above this import will fail within _isys
from pyanaconda.ui.gui.utils import escape_markup
-except ImportError:
+except (RuntimeError, ImportError):
escape_markup = lambda x: x
class InvalidImageSizeError(Exception):
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/669f9a49da574f725e9c9995d3dc3af93201109d
More information about the anaconda-patches
mailing list