From 3bdfc07e2a3043c8880f2035b6412a01a0b9cf0e Mon Sep 17 00:00:00 2001 From: Mike Alexander Date: Thu, 28 Jun 2018 19:39:22 -0700 Subject: [PATCH 1/2] Fix python2->3 conversion breaking the http_post method of client.py so the data wasn't a byte array in the default case anymore --- v1pysdk/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/v1pysdk/client.py b/v1pysdk/client.py index d7aa35a..5424d64 100644 --- a/v1pysdk/client.py +++ b/v1pysdk/client.py @@ -103,7 +103,11 @@ def http_get(self, url): return response def http_post(self, url, data=''): - request = Request(url, data) + encodedData=data + #encode to byte data as is needed if in Python3 or Python2 and it's a string + if (sys.version_info >= (3,0)) or isinstance(data, str): + encodedData=data.encode('utf-8') + request = Request(url, encodedData) request.add_header("Content-Type", "text/xml;charset=UTF-8") response = self.opener.open(request) return response From e8e713a8e828326a0575000f0755eeb6ba9b37cb Mon Sep 17 00:00:00 2001 From: Mike Alexander Date: Thu, 28 Jun 2018 19:42:51 -0700 Subject: [PATCH 2/2] fix encoding checks --- v1pysdk/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v1pysdk/client.py b/v1pysdk/client.py index 5424d64..b1e1859 100644 --- a/v1pysdk/client.py +++ b/v1pysdk/client.py @@ -104,8 +104,8 @@ def http_get(self, url): def http_post(self, url, data=''): encodedData=data - #encode to byte data as is needed if in Python3 or Python2 and it's a string - if (sys.version_info >= (3,0)) or isinstance(data, str): + #encode to byte data as is needed if it's a string + if isinstance(data, str): encodedData=data.encode('utf-8') request = Request(url, encodedData) request.add_header("Content-Type", "text/xml;charset=UTF-8")