Bug report
Bug description:
On windows, if the request.urlretrieve method receives an url pointing to a local file and no filename is provided, then the returned filename will be invalid:
from urllib import request
request.urlretrieve("file:///C:/testdir/testfile.txt")
# ('\\\\\\C:\\testdir\\testfile.txt', <...>)
# Expected 'C:\\testdir\\testfile.txt'
# Other variants of urlretrieve calls work as expected
request.urlretrieve("file:///C:/testdir/testfile.txt", "C:\\testdir\\testcopy.txt")
# ('C:\\testdir\\testcopy.txt', <...>)
request.urlretrieve("https://google.com/")
# ('C:\\Users\\...\\Temp\\tmpwp4pu1bw', <...>)
I would expect that if no copy is necessary then the filename returned by request.urlretrieve would be equal to request.url2pathname(parse.urlparse("file:///C:/testdir/testfile.txt").path)
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
On windows, if the
request.urlretrievemethod receives anurlpointing to a local file and nofilenameis provided, then the returned filename will be invalid:I would expect that if no copy is necessary then the filename returned by
request.urlretrievewould be equal torequest.url2pathname(parse.urlparse("file:///C:/testdir/testfile.txt").path)CPython versions tested on:
3.14
Operating systems tested on:
Windows