urllib: urlretrieve() on Windows, given a local file url and no target filename method returns an invalid filename
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với hành vi của urllib.request.urlretrieve và urllib.request.url2pathname(parse.urlparse(...).path) được mô tả trong báo cáo. Xác minh trường hợp tệp cục bộ không có tên tệp trên Windows, đồng thời giữ nguyên các biến thể đang hoạt động với tên tệp rõ ràng và URL từ xa; hoàn tất khi tên tệp được trả về khớp với đường dẫn Windows ожида kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- networking
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100