python / python/cpython

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

未关闭
#141,647 16 条评论 0 个 reaction 已指派 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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。