Bläddra i källkod

DiskObjectStore: fix py3 TypeError in _read_alternate_paths

The problem happened with relative paths only.
Georges Racinet 4 år sedan
förälder
incheckning
06b65c3c2a
2 ändrade filer med 6 tillägg och 1 borttagningar
  1. 2 1
      dulwich/object_store.py
  2. 4 0
      dulwich/tests/test_object_store.py

+ 2 - 1
dulwich/object_store.py

@@ -582,7 +582,8 @@ class DiskObjectStore(PackBasedObjectStore):
                 if os.path.isabs(line):
                     yield os.fsdecode(line)
                 else:
-                    yield os.fsdecode(os.path.join(self.path, line))
+                    yield os.fsdecode(os.path.join(os.fsencode(self.path),
+                                                   line))
 
     def add_alternate_path(self, path):
         """Add an alternate path to this object store.

+ 4 - 0
dulwich/tests/test_object_store.py

@@ -370,6 +370,10 @@ class DiskObjectStoreTests(PackBasedObjectStoreTests, TestCase):
         store.add_alternate_path(abs_path)
         self.assertEqual(set(store._read_alternate_paths()), {abs_path})
 
+        store.add_alternate_path("relative-path")
+        self.assertIn(os.path.join(store.path, "relative-path"),
+                      set(store._read_alternate_paths()))
+
     def test_corrupted_object_raise_exception(self):
         """Corrupted sha1 disk file should raise specific exception"""
         self.store.add_object(testobject)