diff options
| author | Michal Arbet <michal.arbet@ultimum.io> | 2018-09-05 13:37:30 +0200 |
|---|---|---|
| committer | git-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com> | 2018-09-07 16:47:18 +0000 |
| commit | 688c2a6ac646b0dc1bb66f8567233a0477ce6b60 (patch) | |
| tree | bc052061fedae1982b87f73fae4f1225b0905d15 | |
| parent | 82f413fb5ef4429c45a38a3fd9b70bd0b4f24c46 (diff) | |
| parent | 23db740495383928e98ce198aa01c0c45659536f (diff) | |
2.1.0-3 (patches applied)applied/2.1.0-3applied/debian/buster
Imported using git-ubuntu import.
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | debian/patches/fix-py3-str-bytes-error.patch | 31 | ||||
| -rw-r--r-- | debian/patches/series | 1 | ||||
| -rw-r--r-- | watcherclient/common/httpclient.py | 10 |
4 files changed, 47 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index 46af95c..4d5a41f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-watcherclient (2.1.0-3) unstable; urgency=medium + + * Add fix-py3-str-bytes-error.patch + + -- Michal Arbet <michal.arbet@ultimum.io> Wed, 05 Sep 2018 13:37:30 +0200 + python-watcherclient (2.1.0-2) unstable; urgency=medium * Uploading to unstable. diff --git a/debian/patches/fix-py3-str-bytes-error.patch b/debian/patches/fix-py3-str-bytes-error.patch new file mode 100644 index 0000000..607fd47 --- /dev/null +++ b/debian/patches/fix-py3-str-bytes-error.patch @@ -0,0 +1,31 @@ +Description: Fix watherclient error in py3 + watchercliet will raise error: + Recoverable error: sequence item 0: expected str instance, bytes found + This patch fix this. +Author: zhurong <aaronzhu1121@gmail.com> +Date: Fri, 27 Jul 2018 09:27:56 +0000 +Change-Id: I6fe21766f320b0a09a14202203a5d0451175e1d3 +Origin: upstream, https://review.openstack.org/#/c/585938/ +Last-Update: 2018-09-05 + +diff --git a/watcherclient/common/httpclient.py b/watcherclient/common/httpclient.py +index 6eba147..36a8469 100644 +--- a/watcherclient/common/httpclient.py ++++ b/watcherclient/common/httpclient.py +@@ -354,7 +354,15 @@ + # Read body into string if it isn't obviously image data + body_str = None + if resp.headers.get('Content-Type') != 'application/octet-stream': +- body_str = ''.join([chunk for chunk in body_iter]) ++ # decoding byte to string is necessary for Python 3 compatibility ++ # this issues has not been found with Python 3 unit tests ++ # because the test creates a fake http response of type str ++ # the if statement satisfies test (str) and real (bytes) behavior ++ body_list = [ ++ chunk.decode("utf-8") if isinstance(chunk, bytes) ++ else chunk for chunk in body_iter ++ ] ++ body_str = ''.join(body_list) + self.log_http_response(resp, body_str) + body_iter = six.StringIO(body_str) + else: diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..92d7508 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +fix-py3-str-bytes-error.patch diff --git a/watcherclient/common/httpclient.py b/watcherclient/common/httpclient.py index 6eba147..36a8469 100644 --- a/watcherclient/common/httpclient.py +++ b/watcherclient/common/httpclient.py @@ -354,7 +354,15 @@ class HTTPClient(VersionNegotiationMixin): # Read body into string if it isn't obviously image data body_str = None if resp.headers.get('Content-Type') != 'application/octet-stream': - body_str = ''.join([chunk for chunk in body_iter]) + # decoding byte to string is necessary for Python 3 compatibility + # this issues has not been found with Python 3 unit tests + # because the test creates a fake http response of type str + # the if statement satisfies test (str) and real (bytes) behavior + body_list = [ + chunk.decode("utf-8") if isinstance(chunk, bytes) + else chunk for chunk in body_iter + ] + body_str = ''.join(body_list) self.log_http_response(resp, body_str) body_iter = six.StringIO(body_str) else: |
