Issues in ipaddress.collapse_addresses()
未關閉
還沒有人認領這個 Issue。
3.13
3.14
3.15
3.16
stdlib
type-bug
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
The following issues was discovered during reviewing #141842:
ipaddress.collapse_addresses()supports not only IP networks, but also IP addresses and a mix of them. There are dedicated tests, but this is not documented.ipaddress.collapse_addresses()contains code for supporting also IP interfaces, but it always was broken (it would work if interfaces were not subclasses of addresses). The test for mix of IP addresses and IP interfaces is mislabeled (it says a mix of addresses and networks) and partially commented out (it only tests addresses now, which is mostly a duplicate of other test).- While TypeError is raised immediately for IP addresses of different versions and IP networks of different versions, it is delayed until the start of iteration for a mix of IP addresses and IP networks with addresses and networks having different versions.
- For objects other that IP objects you can get AttributeError instead of TypeError.
My plan for a fix:
- Document support of IP addresses.
- Explicitly forbid IP interfaces.
- Always raise TypeError for invalid types (the code is simpler this way).
- Add tests for corner cases.
For new version only:
- Implement support of IP interfaces and document it as a new feature.
- Either raise TypeError immediately for IP objects of different versions, or remove redundant explicit checks, they will be raised implicitly in comparisons.
Linked PRs
- gh-149723
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從報告中提到的 ipaddress.collapse_addresses() 進入點和現有專用測試開始。在變更行為之前,先檢視連結的 PR gh-149723。完成標準是記錄支援的 IP 位址、決定如何處理 IP 介面、對無效輸入一致地引發 TypeError,以及新增邊界情況測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- networking
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100