`urlparse` ignores the `scheme` parameter when parsing a URL
未關閉
還沒有人認領這個 Issue。
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
urlparse ignores the scheme parameter when determining what part of a URL is the path and hostname.
from urllib.parse import urlparse
# This should be parsed as: http://www.example.com
parsed_url = urlparse('www.example.com', scheme='http')
print(parsed_url)
print(parsed_url.hostname)
ParseResult(scheme='http', netloc='', path='www.example.com', params='', query='', fragment='')
[empty string]
Should return:
ParseResult(scheme='http', netloc='', path='', params='', query='', fragment='')
www.example.com
Per the docs:
The
schemeargument gives the default addressing scheme, to be used only if the URL does not specify one.
CPython versions tested on:
3.8, 3.11
Operating systems tested on:
Windows
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,在受支援的 CPython 版本上重現所回報的 urlparse 行為,並檢查 urllib.parse 的實作與現有的 URL 解析測試。將 scheme 引數的處理方式與文件所述行為進行比較,並判斷所要求的 hostname 解析是否與 URL 語法相容。約定的行為由回歸測試涵蓋即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- networking
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100