diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-01-15 21:25:27 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-01-15 21:25:27 +0000 |
commit | b6b4928effd8ce34c5a56094738876aab5afedec (patch) | |
tree | 79278f541a0e850166fba87b7ac2f82bbe9bfe77 /heatclient | |
parent | 48f74c073ce6990bb0241a37d8305cd6b2209d47 (diff) | |
parent | c3f389e92a2e26f9baddde6065e5534b0072ace3 (diff) | |
download | python-heatclient-b6b4928effd8ce34c5a56094738876aab5afedec.tar.gz |
Merge "Sync strutils from oslo"
Diffstat (limited to 'heatclient')
-rw-r--r-- | heatclient/openstack/common/strutils.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/heatclient/openstack/common/strutils.py b/heatclient/openstack/common/strutils.py index e8386ea..dd152b3 100644 --- a/heatclient/openstack/common/strutils.py +++ b/heatclient/openstack/common/strutils.py @@ -1,5 +1,3 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - # Copyright 2011 OpenStack Foundation. # All Rights Reserved. # @@ -154,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 |