python / python/cpython

Issues in ipaddress.collapse_addresses()

オープン
#149,722 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.13 3.14 3.15 3.16 stdlib type-bug type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

レポートで言及されている既存の専用テストと、エントリポイント ipaddress.collapse_addresses() から始めてください。動作を変更する前に、リンクされている PR gh-149723 を確認してください。完了条件は、サポートされる IP アドレスを文書化し、IP インターフェースの扱いを決定し、無効な入力に対して一貫して TypeError を発生させ、境界ケースのテストを追加することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。