python3 compatibility
fixed unicode/byte string issues for python3
This commit is contained in:
parent
632750565b
commit
c04ba3ac2b
@ -38,7 +38,7 @@ from . import utils
|
||||
__author__ = 'dborowitz@google.com (Dave Borowitz)'
|
||||
|
||||
BLOB_SHA = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
|
||||
BLOB_NEW_CONTENT = 'foo bar\n'
|
||||
BLOB_NEW_CONTENT = b'foo bar\n'
|
||||
|
||||
|
||||
class BlobTest(utils.BareRepoTestCase):
|
||||
@ -67,7 +67,7 @@ class BlobTest(utils.BareRepoTestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(BLOB_NEW_CONTENT, blob.data)
|
||||
self.assertEqual(BLOB_NEW_CONTENT.decode('ascii'), blob.read_raw())
|
||||
self.assertEqual(BLOB_NEW_CONTENT, blob.read_raw())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -52,13 +52,12 @@ def oid_to_hex(oid):
|
||||
return b2a_hex(oid).decode('ascii')
|
||||
|
||||
def gen_blob_sha1(data):
|
||||
m = hashlib.sha1()
|
||||
|
||||
# http://stackoverflow.com/questions/552659/assigning-git-sha1s-without-git
|
||||
git_sha1_format = 'blob %d\0%s' % (len(data), data)
|
||||
m.update(git_sha1_format)
|
||||
m = hashlib.sha1()
|
||||
m.update(('blob %d\0' % len(data)).encode())
|
||||
m.update(data)
|
||||
|
||||
return m.hexdigest().decode('ascii')
|
||||
return m.hexdigest()
|
||||
|
||||
def rmtree(path):
|
||||
"""In Windows a read-only file cannot be removed, and shutil.rmtree fails.
|
||||
|
Loading…
x
Reference in New Issue
Block a user