`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