Issues in ipaddress.collapse_addresses()
Aperta
Nessuno ha ancora preso questa issue.
3.13
3.14
3.15
3.16
stdlib
type-bug
type-feature
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso ipaddress.collapse_addresses() e dai test dedicati esistenti menzionati nel report. Esamina la PR collegata gh-149723 prima di modificare il comportamento. Il lavoro è completato quando sono documentati gli indirizzi IP supportati, è deciso come gestire le interfacce IP, viene sollevato TypeError in modo coerente per gli input non validi e vengono aggiunti test per i casi limite.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100