[pygobject] gi/overrides/Glib.py: Fix running on Windows/non-Unix



commit 93d5cc2986cb3d3d979694b1beb1719d2d8fed53
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jan 25 12:49:18 2013 +0800

    gi/overrides/Glib.py: Fix running on Windows/non-Unix
    
    The definition of self._signal_source uses a Unix-specific GLib API, which
    does not exist or have a direct equivilant on Windows.
    
    Only define and use that variable when we aren't on Windows.

 gi/overrides/GLib.py |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 28a35e2..6f116a3 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -21,6 +21,7 @@
 
 import signal
 import warnings
+import sys
 
 from ..module import get_introspection_module
 from .._gi import (variant_new_tuple, variant_type_from_string, source_new,
@@ -493,16 +494,17 @@ class MainLoop(GLib.MainLoop):
         def _handler(loop):
             loop.quit()
             loop._quit_by_sigint = True
-
-        # compatibility shim, keep around until we depend on glib 2.36
-        if hasattr(GLib, 'unix_signal_add'):
-            fn = GLib.unix_signal_add
-        else:
-            fn = GLib.unix_signal_add_full
-        self._signal_source = fn(GLib.PRIORITY_DEFAULT, signal.SIGINT, _handler, self)
+        if sys.platform != 'win32':
+            # compatibility shim, keep around until we depend on glib 2.36
+            if hasattr(GLib, 'unix_signal_add'):
+                fn = GLib.unix_signal_add
+            else:
+                fn = GLib.unix_signal_add_full
+            self._signal_source = fn(GLib.PRIORITY_DEFAULT, signal.SIGINT, _handler, self)
 
     def __del__(self):
-        GLib.source_remove(self._signal_source)
+        if hasattr(self, '_signal_source'):
+            GLib.source_remove(self._signal_source)
 
     def run(self):
         super(MainLoop, self).run()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]