Replace unicode with six.text_type

The Unicode type is 'unicode' in Python 2 and 'str' on Python 3.
This patch replaces unicode with six.text_type to make Nova
compatible with Python 2 and Python 3.

Blueprint nova-python3

Change-Id: I9e883798129ee3ea692e63cf0466b9cfd400a01d
This commit is contained in:
TuanLAF 2016-07-07 14:03:51 +07:00
parent 3e96b0fde0
commit 926776f4cd
1 changed files with 1 additions and 1 deletions

View File

@ -51,7 +51,7 @@ def parse_sr_info(connection_data, description=''):
sr_identity = "%s/%s/%s" % (params['target'], params['port'],
params['targetIQN'])
# PY2 can only support taking an ascii string to uuid5
if six.PY2 and isinstance(sr_identity, unicode):
if six.PY2 and isinstance(sr_identity, six.text_type):
sr_identity = sr_identity.encode('utf-8')
sr_uuid = str(uuid.uuid5(SR_NAMESPACE, sr_identity))
else: