Commit Diff


commit - 20d53c732fce08641a120c1b7d68a751757f4600
commit + 8c92769c9a5b03bc281b333eb2283b0d81d7c974
blob - eec0c72d69bd3c96f2cf1392a59cf4a4deb45576
blob + 44149dcb47d80bccdb2ccc08f0153047b4fa6f91
--- NEWS
+++ NEWS
@@ -1,5 +1,8 @@
 0.20.43	UNRELEASED
 
+ * Lazily import url2pathname.
+   (Jelmer Vernooij)
+
  * Drop caching of full HTTP response. Attempt #2.
    (jelmer Vernooij, Antoine Lambert, #966)
 
blob - 75c0172028b1033902908ff8f993c50a4915ffff
blob + bb62f2ee37df941a79464f05d15f44d87b2c9062
--- dulwich/client.py
+++ dulwich/client.py
@@ -56,7 +56,6 @@ from urllib.parse import (
     urlunsplit,
     urlunparse,
 )
-from urllib.request import url2pathname
 
 
 import dulwich
@@ -117,6 +116,10 @@ from dulwich.refs import (
 from dulwich.repo import Repo
 
 
+# url2pathname is lazily imported
+url2pathname = None
+
+
 logger = logging.getLogger(__name__)
 
 
@@ -2237,8 +2240,7 @@ HttpGitClient = Urllib3HttpGitClient
 
 
 def _win32_url_to_path(parsed) -> str:
-    """
-    Convert a file: URL to a path.
+    """Convert a file: URL to a path.
 
     https://datatracker.ietf.org/doc/html/rfc8089
     """
@@ -2260,6 +2262,9 @@ def _win32_url_to_path(parsed) -> str:
     else:
         raise NotImplementedError("Non-local file URLs are not supported")
 
+    global url2pathname
+    if url2pathname is None:
+        from urllib.request import url2pathname
     return url2pathname(netloc + path)