[pygobject] Allow passing sockets to io_add_watch on win32



commit 1cb6c470e9d297afda21b73efaccb0b95e519b5d
Author: Lukas K <lu 0x83 eu>
Date:   Fri May 13 21:30:47 2016 +0200

    Allow passing sockets to io_add_watch on win32
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766396

 gi/overrides/GLib.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index c12b4d8..5a7792d 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -22,6 +22,7 @@
 import signal
 import warnings
 import sys
+import socket
 
 from ..module import get_introspection_module
 from .._gi import (variant_type_from_string, source_new,
@@ -726,6 +727,9 @@ def _io_add_watch_get_args(channel, priority_, condition, *cb_and_user_data, **k
     if isinstance(channel, int):
         func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)
         real_channel = GLib.IOChannel.unix_new(channel)
+    elif isinstance(channel, socket.socket) and sys.platform == 'win32':
+        func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)
+        real_channel = GLib.IOChannel.win32_new_socket(channel.fileno())
     elif hasattr(channel, 'fileno'):
         # backwards compatibility: Allow calling with Python file
         func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)


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