From c747023b46fd1c2a584a621ed59cde182b20bab4 Mon Sep 17 00:00:00 2001 From: Ranler Cao Date: Wed, 24 May 2017 17:27:54 +0800 Subject: [PATCH] Fix unicode error for python3 Fix undefined name 'unicode' errors when python3 is used. Change-Id: I6803a1e5154c3815bd57392272630aac689f13fb Signed-off-by: Ranler Cao --- nova/virt/zun/driver.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/virt/zun/driver.py b/nova/virt/zun/driver.py index 850d2a8f6..746b599c5 100644 --- a/nova/virt/zun/driver.py +++ b/nova/virt/zun/driver.py @@ -20,6 +20,7 @@ A Docker Hypervisor which allows running Linux Containers instead of VMs. import os import shutil +import six import socket import time @@ -233,7 +234,9 @@ class DockerDriver(driver.ComputeDriver): self._stop_firewall(instance, network_info) def _encode_utf8(self, value): - return unicode(value).encode('utf-8') + if six.PY2 and not isinstance(value, unicode): + value = unicode(value) + return value.encode('utf-8') def _find_container_by_instance(self, instance): try: