Fix Python 3 related issues.

Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4be89d24
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4be89d24
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4be89d24

Branch: refs/heads/trunk
Commit: 4be89d24b3f8cb5376f476437bda2342baf42043
Parents: ea7409e
Author: Tomaz Muraus <[email protected]>
Authored: Sun Jan 17 22:55:37 2016 +0100
Committer: Tomaz Muraus <[email protected]>
Committed: Sun Jan 17 22:55:37 2016 +0100

----------------------------------------------------------------------
 libcloud/storage/drivers/backblaze_b2.py   | 2 +-
 libcloud/test/storage/test_backblaze_b2.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/4be89d24/libcloud/storage/drivers/backblaze_b2.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/backblaze_b2.py 
b/libcloud/storage/drivers/backblaze_b2.py
index 2481e51..bb37025 100644
--- a/libcloud/storage/drivers/backblaze_b2.py
+++ b/libcloud/storage/drivers/backblaze_b2.py
@@ -317,7 +317,7 @@ class BackblazeB2StorageDriver(StorageDriver):
         headers['Content-Type'] = content_type
 
         sha1 = hashlib.sha1()
-        sha1.update(data.encode())
+        sha1.update(b(data))
         headers['X-Bz-Content-Sha1'] = sha1.hexdigest()
 
         # Include optional meta-data (up to 10 items)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4be89d24/libcloud/test/storage/test_backblaze_b2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_backblaze_b2.py 
b/libcloud/test/storage/test_backblaze_b2.py
index 6ce01e8..871f52b 100644
--- a/libcloud/test/storage/test_backblaze_b2.py
+++ b/libcloud/test/storage/test_backblaze_b2.py
@@ -85,7 +85,7 @@ class BackblazeB2StorageDriverTestCase(unittest.TestCase):
         container = self.driver.list_containers()[0]
         obj = self.driver.list_container_objects(container=container)[0]
         result = self.driver.download_object_as_stream(obj=obj)
-        result = ''.join(list(result))
+        result = ''.join([x.decode('utf-8') for x in list(result)])
         self.assertEqual(result, 'ab')
 
     def test_upload_object(self):

Reply via email to