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
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user