urllib: urlretrieve() on Windows, given a local file url and no target filename method returns an invalid filename
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Linked PRs
- gh-156550
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelo comportamento de urllib.request.urlretrieve e urllib.request.url2pathname(parse.urlparse(...).path) descrito no relatório. Verifique o caso de arquivo local sem nome de arquivo no Windows, preservando as variantes funcionais de nome de arquivo explícito e URL remota; está concluído quando o nome de arquivo retornado corresponde ao caminho do Windows esperado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- networking
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 35/100