diff options
author | Cyril Roelandt <cyril.roelandt@enovance.com> | 2014-02-25 16:03:34 +0100 |
---|---|---|
committer | Cyril Roelandt <cyril.roelandt@enovance.com> | 2014-03-03 19:12:39 +0100 |
commit | 21c422f730c75d5cf91421aeb2d960f188b2a32a (patch) | |
tree | 60c55071af1fae3b5ca7692c1ec7dfe0dda83905 | |
parent | 46bf4527109f8d185d017bcbe16c23f502ab233b (diff) | |
download | python-glanceclient-21c422f730c75d5cf91421aeb2d960f188b2a32a.tar.gz |
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
-rw-r--r-- | glanceclient/common/utils.py | 2 | ||||
-rw-r--r-- | 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() |