python / python/cpython

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

Abierto
#141,647 16 comentarios 0 reacciones 1 asignado Ver en GitHub

@picnixz ya está trabajando en esto.

Desde el 22/11/2025.

stdlib type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.