[issue41820] ipaddress Library gives me incorrect results

Eric V. Smith report at bugs.python.org
Sun Sep 20 13:04:08 EDT 2020


Eric V. Smith <eric at trueblade.com> added the comment:

Please do not include screen shots in bug reports. They've unfriendly to people who use screen readers or other accessibility software. Instead, please copy and paste (or retype, if needed) the text into the comment section.

> '172.16.254.00' *is not* equivalent to '172.16.254.0'

Do you have an RFC or other document that makes that clear? I've never seen an IP address library that makes a distinction between '00' and '0'. But I'm happy to learn something new, if you can point to a standard.

If this were going to be an error, it would be in the call to ipaddress.ip_address() or its equivalent. It would raise ValueError, like it does for other strings that don't represent valid addresses. But for backward compatibility reasons, unless there's a standard that explicitly disallows .00, I doubt we'd change the code to raise an exception. And even if there were a standard that says .00 is not a valid address, I'd be reluctant to make a change here. We could potentially break people's code, and we'd need a very good reason to do that.

Also, is this causing you a practical problem? Is there somewhere you're getting a .00 address and you'd like to treat it as being invalid?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41820>
_______________________________________


More information about the Python-bugs-list mailing list