This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ipaddress.IPv4Network allows prefix > 32
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: John Florian, jedwards, matrixise, pitrou, remi.lapeyre, xtreak
Priority: normal Keywords: patch

Created on 2019-02-13 16:13 by John Florian, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 11844 open matrixise, 2019-02-13 20:45
Messages (5)
msg335460 - (view) Author: John Florian (John Florian) Date: 2019-02-13 16:13
I wanted a simple is_valid_ipv4_network() function, so I wrote one and a bunch of unit tests where I discovered that I can legally:

>>> n = IPv4Network(('', 12345678))
>>> n
>>> n.prefixlen
>>> n.max_prefixlen

I assume this is a bug.
msg335475 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-13 20:47
I proposed my PR but I prefer a review because in the code of ipaddress, there is a function for the validation of an address with the netmask. Maybe we could use this function and try to refactor/improve the current code.
msg337228 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-03-05 16:44
Hi @maxtrixise, thanks for PR,

> there is a function for the validation of an address with the netmask

Which one do you want to use?
msg337230 - (view) Author: James Edwards (jedwards) * Date: 2019-03-05 16:59
It may be worth also addressing the fact that IPv6Network makes no restriction on it's netmask (when specified as a tuple).
msg342795 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-05-18 12:19
See also issue36845 that seems to have fixed this.
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80170
2019-05-18 12:19:37xtreaksetnosy: + xtreak
messages: + msg342795
2019-03-05 16:59:48jedwardssetnosy: + jedwards
messages: + msg337230
2019-03-05 16:44:02remi.lapeyresetmessages: + msg337228
2019-02-13 20:47:15matrixisesetnosy: + matrixise
messages: + msg335475
2019-02-13 20:45:06matrixisesetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request11875
2019-02-13 17:06:13SilentGhostsetnosy: + pitrou

type: behavior
components: + Library (Lib)
stage: test needed
2019-02-13 16:14:52remi.lapeyresetnosy: + remi.lapeyre
2019-02-13 16:13:55John Floriancreate