From 0c8eaf50a9e2b3317f3eba62f205546904bc6d74 Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Thu, 5 Jul 2018 11:13:40 +0700 Subject: [PATCH] Replace unicode with six.text_type The unicode() built-in does not exist under Python 3 so use six.text_type, which is set correctly to str or unicode, instead. Change-Id: Ieb29486c99400b4a10ce642cb3adc83f5e4420f6 --- swauth/middleware.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swauth/middleware.py b/swauth/middleware.py index 8732640..92d4a48 100644 --- a/swauth/middleware.py +++ b/swauth/middleware.py @@ -20,6 +20,7 @@ import hmac from httplib import HTTPConnection from httplib import HTTPSConnection import json +import six import swift from time import gmtime from time import strftime @@ -374,9 +375,9 @@ class Swauth(object): password = creds_dict['hash'] # https://bugs.python.org/issue5285 - if isinstance(password, unicode): + if isinstance(password, six.text_type): password = password.encode('utf-8') - if isinstance(msg, unicode): + if isinstance(msg, six.text_type): msg = msg.encode('utf-8') valid_signature = base64.encodestring(hmac.new(