Repository_read().data should be binary data

This commit is contained in:
Nico von Geyso
2013-03-12 23:40:24 +01:00
parent b60f24c127
commit fa8ef0d6d4
2 changed files with 7 additions and 3 deletions

View File

@@ -380,7 +380,11 @@ Repository_read(Repository *self, PyObject *py_hex)
return NULL;
tuple = Py_BuildValue(
#if PY_MAJOR_VERSION == 2
"(ns#)",
#else
"(ny#)",
#endif
git_odb_object_type(obj),
git_odb_object_data(obj),
git_odb_object_size(obj));

View File

@@ -70,14 +70,14 @@ class RepositoryTest(utils.BareRepoTestCase):
ab = self.repo.read(A_BIN_SHA)
a = self.repo.read(A_HEX_SHA)
self.assertEqual(ab, a)
self.assertEqual((GIT_OBJ_BLOB, 'a contents\n'), a)
self.assertEqual((GIT_OBJ_BLOB, b'a contents\n'), a)
a2 = self.repo.read('7f129fd57e31e935c6d60a0c794efe4e6927664b')
self.assertEqual((GIT_OBJ_BLOB, 'a contents 2\n'), a2)
self.assertEqual((GIT_OBJ_BLOB, b'a contents 2\n'), a2)
a_hex_prefix = A_HEX_SHA[:4]
a3 = self.repo.read(a_hex_prefix)
self.assertEqual((GIT_OBJ_BLOB, 'a contents\n'), a3)
self.assertEqual((GIT_OBJ_BLOB, b'a contents\n'), a3)
def test_write(self):
data = b"hello world"