[chrome-gnome-shell] connector: fix for python2 older than 2.7.6.



commit d863233a741c9b9eb82ab6cbc8e904153bcea0d2
Author: Yuri Konotopov <ykonotopov gmail com>
Date:   Thu Mar 31 19:20:33 2016 +0300

    connector: fix for python2 older than 2.7.6.
    
    Prior to python 2.7.6 struct constructor not accepts unicode arguments
    (https://bugs.python.org/issue19099).
    Force struct arguments to be byte literals.
    
    Fixes: https://github.com/nE0sIghT/chrome-gnome-shell-mirror/issues/1

 connector/gs-chrome-connector.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/connector/gs-chrome-connector.py b/connector/gs-chrome-connector.py
index 888b5c2..4c253e4 100755
--- a/connector/gs-chrome-connector.py
+++ b/connector/gs-chrome-connector.py
@@ -48,9 +48,9 @@ def send_message(response):
     try:
         # Write message size.
         if BUFFER_SUPPORTED:
-            sys.stdout.buffer.write(struct.pack('I', message_length))
+            sys.stdout.buffer.write(struct.pack(b'I', message_length))
         else:
-            sys.stdout.write(struct.pack('I', message_length))
+            sys.stdout.write(struct.pack(b'I', message_length))
 
         # Write the message itself.
         sys.stdout.write(message)
@@ -100,7 +100,7 @@ def read_thread_func(proxy, mainLoop):
             break
 
         # Unpack message length as 4 byte integer.
-        text_length = struct.unpack('i', text_length_bytes)[0]
+        text_length = struct.unpack(b'i', text_length_bytes)[0]
 
         # Read the text (JSON object) of the message.
         if BUFFER_SUPPORTED:


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