urllib: urlretrieve() on Windows, given a local file url and no target filename method returns an invalid filename
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
レポートで説明されている urllib.request.urlretrieve と urllib.request.url2pathname(parse.urlparse(...).path) の動作から始めてください。Windows でファイル名のないローカルファイルのケースを検証し、動作している明示的なファイル名とリモート URL の各バリアントを維持してください。返されるファイル名が期待される Windows パスと一致すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- networking
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100