python / python/cpython

Use of `.version` attribute in `ipaddress` classes break many methods

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

@picnixz がすでに取り組んでいます。

2025年11月22日 から。

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

説明

Bug report

Bug description:

The following self-contained snippet behaves correctly with python 3.13 and with 3.14 IF I remove the version attribute.

But with 3.14 and the version attribute, the __eq__ method of AlwaysTrue is never called, and the script prints False for both.

import sys
from ipaddress import IPv4Network, IPv6Network


class AlwaysTrue:
    # without this attribute, everything works correctly
    version = 42

    def __eq__(self, other) -> bool:
        return True


print('sys.version', sys.version)
print('IPv4Network == AlwaysTrue', IPv4Network('43.48.0.0/12') == AlwaysTrue())
print('IPv6Network == AlwaysTrue', IPv6Network('::eeff:ae3f:d473/128') == AlwaysTrue())
CPython versions tested on:

3.14

Operating systems tested on:

macOS and linux

Linked PRs
  • gh-141651
  • gh-141842

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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