From 34608c9503798a00e9868716d2fbfab8bdee51dc Mon Sep 17 00:00:00 2001 From: Yang Hongyang Date: Sat, 27 Feb 2016 21:36:02 +0800 Subject: [PATCH] Convert bytes to string in get_id for python3 compatibility base64.b32encode() will return bytes in python3, let's convert it to string. Partially-Implements: blueprint magnum-python3 Change-Id: I8c9920e29e090f6b68aa95943484bea6af937eb3 --- magnum/common/short_id.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/magnum/common/short_id.py b/magnum/common/short_id.py index 03dbd8d360..1568259baa 100644 --- a/magnum/common/short_id.py +++ b/magnum/common/short_id.py @@ -51,7 +51,10 @@ def get_id(source_uuid): # The first 12 bytes (= 60 bits) of base32-encoded output is our data encoded = base64.b32encode(six.b(random_bytes))[:12] - return encoded.lower() + if six.PY3: + return encoded.lower().decode('utf-8') + else: + return encoded.lower() def generate_id():