Google backup: correct string encoding between py 2 and 3

Correcting encode() and decode() methods of 8-bit and Unicode
string objects.

In Python 2, Both 8-bit and Unicode strings had both methods
and the type of the return value was based on the specific
encoding passed in.

In Python 3, Text strings only have an encode() method, and
that method can only be used with codecs that produce bytes
objects. Similarly bytes and bytearray objects only have a
decode() method which can only be used with codecs that
produce string objects.

Change-Id: I214a786858655b8caf9612f3da5403c7d0bb7387
Closes-Bug: #1831735
This commit is contained in:
Pablo Caruana 2019-08-14 14:37:59 +02:00 committed by Sean McGinnis
parent dff0f7b2c1
commit 38d581996b
1 changed files with 1 additions and 1 deletions

View File

@ -323,7 +323,7 @@ class GoogleObjectWriter(object):
md5 = hashlib.md5(self.data).digest()
if six.PY3:
md5 = md5.encode('utf-8')
etag = etag.encode('utf-8')
etag = bytes(etag, 'utf-8')
md5 = base64.b64encode(md5)
if etag != md5:
err = _('MD5 of object: %(object_name)s before: '