mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
GH-125866: Preserve Windows drive letter case in file URIs (#127138)
Stop converting Windows drive letters to uppercase in `urllib.request.pathname2url()` and `url2pathname()`. This behaviour is unnecessary and inconsistent with pathlib's file URI implementation.
This commit is contained in:
parent
a13e94d84b
commit
cc813e10ff
4 changed files with 13 additions and 2 deletions
|
@ -35,7 +35,7 @@ def url2pathname(url):
|
|||
if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
|
||||
error = 'Bad URL: ' + url
|
||||
raise OSError(error)
|
||||
drive = comp[0][-1].upper()
|
||||
drive = comp[0][-1]
|
||||
tail = urllib.parse.unquote(comp[1].replace('/', '\\'))
|
||||
return drive + ':' + tail
|
||||
|
||||
|
@ -60,7 +60,7 @@ def pathname2url(p):
|
|||
# DOS drive specified. Add three slashes to the start, producing
|
||||
# an authority section with a zero-length authority, and a path
|
||||
# section starting with a single slash.
|
||||
drive = f'///{drive.upper()}'
|
||||
drive = f'///{drive}'
|
||||
|
||||
drive = urllib.parse.quote(drive, safe='/:')
|
||||
tail = urllib.parse.quote(tail)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue