Handle exception unreffing Variant at exit
Handle exception unreffing Variant at exit

Calling unref will cause gi and gi.repository.GLib to be imported.
However, if the program is exiting, then these modules have likely been
removed from sys.modules and will raise an exception. Assume that's the
case for ImportError and ignore the exception since everything will be
cleaned up, anyways.

This can be triggered with the following trivial program:

$ python3 -c 'from gi.repository import GLib; v = GLib.Variant("s", "foo")'
Exception ignored in:

Adding some debug code to show the full exception revealed this:

Traceback (most recent call last):
  File "/home/dan/src/pygobject/build3/gi/overrides/GLib.py", line 265, in __del__
    self.unref()
ImportError: import of 'gi.repository.GLib' halted; None in sys.modules

https://bugzilla.gnome.org/show_bug.cgi?id=776092

GNOME/pygobject,pexip/pygobject,GNOME/pygobject,pexip/pygobject,pexip/pygobject,GNOME/pygobject