python / python/cpython

`IPv6Network.next_network()` raises the wrong error when addresses run out

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

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

stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug description:

_BaseNetwork.next_network() guards address-space exhaustion with except OverflowError, which only the IPv4 path raises, so on IPv6 the internal ValueError from _string_from_ip_int() escapes instead.

from ipaddress import IPv4Network, IPv6Network

for net in (IPv4Network('255.255.255.0/24'),
            IPv6Network('ffff:ffff:ffff:ffff:ffff:ffff:ffff:0/112')):
    try:
        net.next_network()
    except ValueError as e:
        print(f"{net}: {e}")

Output:

255.255.255.0/24: out of address space, cannot make another /24 network
ffff:ffff:ffff:ffff:ffff:ffff:ffff:0/112: IPv6 address is too large

Expected: out of address space, cannot make another /112 network, the message Doc/library/ipaddress.rst gives for next_network().

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-156681
  • gh-157280

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

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

はじめの一歩

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

調査の方向性

_BaseNetwork.next_network() と Doc/library/ipaddress.rst 内の next_network() の文言を確認し、その後 issue の IPv4 および IPv6 の例を再現します。完了条件は、IPv6 アドレス空間の枯渇時に、/112 ネットワークについて「IPv6 address is too large」ではなく、文書化されている「out of address space」というメッセージが報告されることです。

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

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

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

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