From 56ea52549933217c4c7a744d9a54f2ff0a44f276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20V=C3=A1radi?= Date: Mon, 10 Sep 2018 15:05:46 +0200 Subject: [PATCH] Use encode()/decode() with Python 3 only --- shell_integration/nautilus/syncstate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell_integration/nautilus/syncstate.py b/shell_integration/nautilus/syncstate.py index c04b7b37ca..783d2ed403 100644 --- a/shell_integration/nautilus/syncstate.py +++ b/shell_integration/nautilus/syncstate.py @@ -63,7 +63,7 @@ class SocketConnect(GObject.GObject): self._watch_id = 0 self._sock = None self._listeners = [self._update_registered_paths, self._get_version] - self._remainder = ''.encode() + self._remainder = ''.encode() if python3 else '' self.protocolVersion = '1.0' self.nautilusVFSFile_table = {} # not needed in this object actually but shared # all over the other objects. @@ -82,7 +82,7 @@ class SocketConnect(GObject.GObject): # print("Server command: " + cmd) if self.connected: try: - self._sock.send(cmd.encode()) + self._sock.send(cmd.encode() if python3 else cmd) except: print("Sending failed.") self.reconnect() @@ -134,7 +134,8 @@ class SocketConnect(GObject.GObject): return [] data = self._remainder[:end] self._remainder = self._remainder[end+1:] - return data.decode().split('\n') + data = data.decode() if python3 else data + return data.split('\n') # Notify is the raw answer from the socket def _handle_notify(self, source, condition):