[3.14] GH-137059: url2pathname(): fix support for drive letter in netloc (GH-137060) (#137144)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-07-28 21:43:15 +02:00 committed by GitHub
parent fbc2a0ca9a
commit aeb55ebb07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View file

@ -1660,7 +1660,10 @@ def url2pathname(url, *, require_scheme=False, resolve_host=False):
if scheme != 'file':
raise URLError("URL is missing a 'file:' scheme")
if os.name == 'nt':
if not _is_local_authority(authority, resolve_host):
if authority[1:2] == ':':
# e.g. file://c:/file.txt
url = authority + url
elif not _is_local_authority(authority, resolve_host):
# e.g. file://server/share/file.txt
url = '//' + authority + url
elif url[:3] == '///':