From 21c422f730c75d5cf91421aeb2d960f188b2a32a Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 25 Feb 2014 16:03:34 +0100 Subject: Python 3: do not use the unicode() function It is Python2-specific, and should not be used in code intended to be portable. Change-Id: Ibebef1a7e51a7444538275d22d444c926b8b4dec Closes-Bug: 1284677 --- glanceclient/common/utils.py | 2 +- glanceclient/v2/images.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index fd284c1..04350d5 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -250,7 +250,7 @@ def getsockopt(self, *args, **kwargs): def exception_to_str(exc): try: - error = unicode(exc) + error = six.text_type(exc) except UnicodeError: try: error = str(exc) diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py index e475c50..ab07a6b 100644 --- a/glanceclient/v2/images.py +++ b/glanceclient/v2/images.py @@ -18,6 +18,7 @@ from six.moves.urllib import parse import warlock +from glanceclient.common import utils from glanceclient.openstack.common import strutils DEFAULT_PAGE_SIZE = 20 @@ -125,7 +126,7 @@ class Controller(object): try: setattr(image, key, value) except warlock.InvalidOperation as e: - raise TypeError(unicode(e)) + raise TypeError(utils.exception_to_str(e)) resp, body = self.http_client.json_request('POST', url, body=image) #NOTE(esheffield): remove 'self' for now until we have an elegant @@ -146,7 +147,7 @@ class Controller(object): try: setattr(image, key, value) except warlock.InvalidOperation as e: - raise TypeError(unicode(e)) + raise TypeError(utils.exception_to_str(e)) if remove_props is not None: cur_props = image.keys() -- cgit v1.2.1