diff options
author | Victor Stinner <vstinner@redhat.com> | 2015-05-20 11:23:00 -0700 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2015-05-20 11:23:00 -0700 |
commit | 22ace8fd78738a33b2e08c47ab37384b90e43de2 (patch) | |
tree | deb7ffa0f368658e1f2191308385d66d1062ae86 /glance_store/common | |
parent | 7f6a18b041eba88133db7ac5518cb2163bee7e03 (diff) | |
download | glance_store-22ace8fd78738a33b2e08c47ab37384b90e43de2.tar.gz |
Port exception_to_str() to Python 3
On Python 3, exception messages are unicode strings. There is no need to
decode them.
Skip the test on the "ignore" error handler on Python 3, it's specific
to Python 2.
Change-Id: Ieec9e1e1f7a0fc901271fd74eca357fe1cf6a975
Diffstat (limited to 'glance_store/common')
-rw-r--r-- | glance_store/common/utils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/glance_store/common/utils.py b/glance_store/common/utils.py index 48618dc..47571c0 100644 --- a/glance_store/common/utils.py +++ b/glance_store/common/utils.py @@ -150,4 +150,6 @@ def exception_to_str(exc): except UnicodeError: error = ("Caught '%(exception)s' exception." % {"exception": exc.__class__.__name__}) - return encodeutils.safe_encode(error, errors='ignore') + if six.PY2: + error = encodeutils.safe_encode(error, errors='ignore') + return error |