summaryrefslogtreecommitdiff
path: root/nova/utils.py
diff options
context:
space:
mode:
authorTakashi Natsume <takanattie@gmail.com>2020-05-09 09:34:25 +0000
committerTakashi Natsume <takanattie@gmail.com>2020-08-15 07:45:23 +0000
commit28ed0c5c9a7572c002e520685bed60ccc706175b (patch)
tree22700512c8727ccb213225d0eb9505f23342a447 /nova/utils.py
parent1c2cccab71def3ccf46e21fe14c0022686481d1a (diff)
downloadnova-28ed0c5c9a7572c002e520685bed60ccc706175b.tar.gz
Remove six.PY2 and six.PY3
Remove six.PY2 and six.PY3. Subsequent patches will replace other six usages. Change-Id: Iccce0ab50eee515e533ab36c8e7adc10cb3f7019 Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 0d601710c1..d7845bae06 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -368,11 +368,9 @@ def sanitize_hostname(hostname, default_name=None):
{'hostname': name, 'truncated_name': name[:63]})
return name[:63]
- if isinstance(hostname, six.text_type):
+ if isinstance(hostname, str):
# Remove characters outside the Unicode range U+0000-U+00FF
- hostname = hostname.encode('latin-1', 'ignore')
- if six.PY3:
- hostname = hostname.decode('latin-1')
+ hostname = hostname.encode('latin-1', 'ignore').decode('latin-1')
hostname = truncate_hostname(hostname)
hostname = re.sub('[ _]', '-', hostname)
@@ -809,8 +807,6 @@ def get_obj_repr_unicode(obj):
else it converts the repr() to unicode.
"""
obj_repr = repr(obj)
- if not six.PY3:
- obj_repr = six.text_type(obj_repr, 'utf-8')
return obj_repr
@@ -1039,13 +1035,10 @@ def generate_hostid(host, project_id):
return ""
-if six.PY2:
- nested_contexts = contextlib.nested
-else:
- @contextlib.contextmanager
- def nested_contexts(*contexts):
- with contextlib.ExitStack() as stack:
- yield [stack.enter_context(c) for c in contexts]
+@contextlib.contextmanager
+def nested_contexts(*contexts):
+ with contextlib.ExitStack() as stack:
+ yield [stack.enter_context(c) for c in contexts]
def normalize_rc_name(rc_name):