diff --git a/magnumclient/common/httpclient.py b/magnumclient/common/httpclient.py index 429f0550..ecf7e4a2 100644 --- a/magnumclient/common/httpclient.py +++ b/magnumclient/common/httpclient.py @@ -167,7 +167,15 @@ class HTTPClient(object): # Read body into string if it isn't obviously image data body_str = None if resp.getheader('content-type', None) != 'application/octet-stream': - body_str = ''.join([chunk for chunk in body_iter]) + # decoding byte to string is necessary for Python 3.4 compatibility + # this issues has not been found with Python 3.4 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/magnumclient/shell.py b/magnumclient/shell.py index 8b9cf9ab..550a901e 100644 --- a/magnumclient/shell.py +++ b/magnumclient/shell.py @@ -396,6 +396,10 @@ class OpenStackMagnumShell(object): def main(self, argv): + # NOTE(Christoph Jansen): With Python 3.4 argv somehow becomes a Map. + # This hack fixes it. + argv = list(argv) + # Parse args once to find version and debug settings parser = self.get_base_parser() (options, args) = parser.parse_known_args(argv)