summaryrefslogtreecommitdiff
path: root/keystoneclient/openstack
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@enovance.com>2013-12-17 22:44:14 +0100
committerChmouel Boudjnah <chmouel@enovance.com>2014-01-08 10:57:00 +0100
commit09b01ac93bcf68a9ac6fb3454e50b73afb390848 (patch)
tree510caaae83b58070bd34f012469fd2c167079bb1 /keystoneclient/openstack
parent0b25aa7c80e1686be848b8dbde3b7a02d53b0a72 (diff)
downloadpython-keystoneclient-09b01ac93bcf68a9ac6fb3454e50b73afb390848.tar.gz
Sync strutils from oslo
Sync strutils from oslo which fix safe_encode under py3, this gets keystone CLI to properly output results. 84d461 Fix a bug in safe_encode where it returns a bytes object in py3 Closes-Bug: 1260824 Change-Id: Idf0f3a51f5cfe3077395b53da66a12955449861f
Diffstat (limited to 'keystoneclient/openstack')
-rw-r--r--keystoneclient/openstack/common/strutils.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/keystoneclient/openstack/common/strutils.py b/keystoneclient/openstack/common/strutils.py
index be238d5..8630aa8 100644
--- a/keystoneclient/openstack/common/strutils.py
+++ b/keystoneclient/openstack/common/strutils.py
@@ -152,11 +152,17 @@ def safe_encode(text, incoming=None,
sys.getdefaultencoding())
if isinstance(text, six.text_type):
- return text.encode(encoding, errors)
+ if six.PY3:
+ return text.encode(encoding, errors).decode(incoming)
+ else:
+ return text.encode(encoding, errors)
elif text and encoding != incoming:
# Decode text before encoding it with `encoding`
text = safe_decode(text, incoming, errors)
- return text.encode(encoding, errors)
+ if six.PY3:
+ return text.encode(encoding, errors).decode(incoming)
+ else:
+ return text.encode(encoding, errors)
return text