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

Attempt to be compatible with the urlparse module found in older Pythons.

Max Bowsher 14 жил өмнө
parent
commit
ddc65f0e5a

+ 6 - 0
dulwich/client.py

@@ -41,6 +41,12 @@ from dulwich.pack import (
     )
 
 
+# Python 2.6.6 included these in urlparse.uses_netloc upstream. Do
+# monkeypatching to enable similar behaviour in earlier Pythons:
+for scheme in ('git', 'git+ssh'):
+    if scheme not in urlparse.uses_netloc:
+        urlparse.uses_netloc.append(scheme)
+
 def _fileno_can_read(fileno):
     """Check if a file descriptor is readable."""
     return len(select.select([fileno], [], [], 0)[0]) > 0

+ 3 - 1
dulwich/tests/test_client.py

@@ -125,7 +125,9 @@ class GitClientTests(TestCase):
         self.assertEquals('foo.bar/baz', path)
 
     def test_get_transport_and_path_error(self):
-        self.assertRaises(ValueError, get_transport_and_path, 'foo://bar/baz')
+        # Need to use a known urlparse.uses_netloc URL scheme to get the
+        # expected parsing of the URL on Python versions less than 2.6.5
+        self.assertRaises(ValueError, get_transport_and_path, 'prospero://bar/baz')
 
 
 class SSHGitClientTests(TestCase):