Comment 4 for bug 1574399

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

You are trying to make some modules optional, e.g. GConf. So if the package is not available, terminator should still work.

We used to have:

try:
    import gi
    from gi.repository import GConf
except ImportError:
    dbg('Unable to import gconf, GNOME defaults unavailable')

If gi or GConf are not available, that throws an ImportError, which you catch and handle, so everything is fine, and you continue to run without GConf.

However, we now have:

try:
    import gi
    gi.require_version('GConf','2.0')
    from gi.repository import GConf
except ImportError:
    dbg('Unable to import gconf, GNOME defaults unavailable')

If you don't have GConf, that will fail on gi.require_version, which will throw a ValueError. Since ValueError is not handled, we crash:

emilio@tatooine:~/src/terminator-gtk3$ ./terminator
Traceback (most recent call last):
  File "./terminator", line 47, in <module>
    import terminatorlib.optionparse
  File "/home/emilio/src/terminator-gtk3/terminatorlib/optionparse.py", line 25, in <module>
    import config
  File "/home/emilio/src/terminator-gtk3/terminatorlib/config.py", line 84, in <module>
    gi.require_version('GConf','2.0')
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 118, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace GConf not available

Handling both ImportError and ValueError explicitly would be fine as well indeed.

Hope that's clearer.