2
0
Эх сурвалжийг харах

Support python3 in objectspec.

Jelmer Vernooij 10 жил өмнө
parent
commit
5bc12a0f35

+ 4 - 0
dulwich/objectspec.py

@@ -27,6 +27,8 @@ def parse_object(repo, objectish):
     :return: A git object
     :raise KeyError: If the object can not be found
     """
+    if getattr(objectish, "encode", None) is not None:
+        objectish = objectish.encode('ascii')
     return repo[objectish]
 
 
@@ -39,4 +41,6 @@ def parse_commit_range(repo, committishs):
     :raise KeyError: When the reference commits can not be found
     :raise ValueError: If the range can not be parsed
     """
+    if getattr(committishs, "encode", None) is not None:
+        committishs = committishs.encode('ascii')
     return iter([repo[committishs]])

+ 1 - 4
dulwich/tests/test_objectspec.py

@@ -35,11 +35,9 @@ from dulwich.tests import (
     )
 from dulwich.tests.utils import (
     build_commit_graph,
-    skipIfPY3,
     )
 
 
-@skipIfPY3
 class ParseObjectTests(TestCase):
     """Test parse_object."""
 
@@ -49,12 +47,11 @@ class ParseObjectTests(TestCase):
 
     def test_blob_by_sha(self):
         r = MemoryRepo()
-        b = Blob.from_string("Blah")
+        b = Blob.from_string(b"Blah")
         r.object_store.add_object(b)
         self.assertEqual(b, parse_object(r, b.id))
 
 
-@skipIfPY3
 class ParseCommitRangeTests(TestCase):
     """Test parse_commit_range."""