From a86d4e11a92b427d5f1b8709c15cd8ae6c3be6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czarnota?= Date: Sun, 2 Aug 2015 22:03:56 +0200 Subject: [PATCH 1/2] response.startswith should accept bytes --- ts3/protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts3/protocol.py b/ts3/protocol.py index 937f5ff..7dd8800 100644 --- a/ts3/protocol.py +++ b/ts3/protocol.py @@ -131,7 +131,7 @@ class TS3Proto(): data = '' response = self._telnet.read_until(b"\n\r", self._timeout) - if not response.startswith("error"): + if not response.startswith(b"error"): # what we just got was extra data data = response response = self._telnet.read_until(b"\n\r", self._timeout) From 8d356e32b01058cd0954cc980d8c80ca872e7715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czarnota?= Date: Sun, 2 Aug 2015 22:25:55 +0200 Subject: [PATCH 2/2] Fixed some issues with bytes vs str mismatch --- ts3/protocol.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ts3/protocol.py b/ts3/protocol.py index 7dd8800..36b3d47 100644 --- a/ts3/protocol.py +++ b/ts3/protocol.py @@ -128,7 +128,7 @@ class TS3Proto(): with self.io_lock: self._telnet.write(commandstr.encode('utf-8') + b"\n\r") - data = '' + data = b'' response = self._telnet.read_until(b"\n\r", self._timeout) if not response.startswith(b"error"): @@ -136,7 +136,7 @@ class TS3Proto(): data = response response = self._telnet.read_until(b"\n\r", self._timeout) - return TS3Response(response, data) + return TS3Response(response.decode('utf-8'), data.decode('utf-8')) def check_connection(self): if not self.is_connected: @@ -199,7 +199,6 @@ class TS3Proto(): @param data: data string @type data: string """ - data = data.strip() multipart = data.split('|')