Skip to content

Commit

Permalink
python3: Fix traceback while running tests
Browse files Browse the repository at this point in the history
Fix:

TypeError: Unicode-objects must be encoded before hashing

while running tests. This is due to the fact in python3 hashlib.md5
works with bytes and we are passing unicode strings.

Change-Id: I27a57d6afb2412e11bc2802e4559d56c5b5592a9
Signed-off-by: Chuck Short <chuck.short@canonical.com>
  • Loading branch information
Chuck Short committed Aug 13, 2013
1 parent 23ac42a commit 8dbd684
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion novaclient/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def completion_cache(self, cache_type, obj_class, mode):
# pair
username = utils.env('OS_USERNAME', 'NOVA_USERNAME')
url = utils.env('OS_URL', 'NOVA_URL')
uniqifier = hashlib.md5(username + url).hexdigest()
uniqifier = hashlib.md5(username.encode('utf-8') +
url.encode('utf-8')).hexdigest()

cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))

Expand Down

0 comments on commit 8dbd684

Please sign in to comment.