Whole file
python-validators/validators
The author described this change as “fix(ip_address): properly handle private is false”. It counts as a record because the check below fails on the code as it stood at d46cd586b and passes on 7c0e60539, with nothing else changed between the two runs.
Projectpython-validators/validators
Fix saved2024-05-09
Sharing licenceMIT · LICENSE.txt
Change size+4 −3
What the code was meant to do, written into the code itself as a save note
fix(ip_address): properly handle private is false
The change
| 19 | 19 | def _check_private_ip(value: str, is_private: Optional[bool]): | |
| 20 | 20 | if is_private is None: | |
| 21 | 21 | return True | |
| 22 | - | if is_private and ( | |
| 22 | + | if ( | |
| 23 | 23 | any( | |
| 24 | 24 | value.startswith(l_bit) | |
| 25 | 25 | for l_bit in { | |
| ⋯ | |||
| 33 | 33 | or re.match(r"^172\.(?:1[6-9]|2\d|3[0-1])\.", value) # private | |
| 34 | 34 | or re.match(r"^(?:22[4-9]|23[0-9]|24[0-9]|25[0-5])\.", value) # broadcast | |
| 35 | 35 | ): | |
| 36 | - | return True | |
| 37 | - | return False | |
| 36 | + | return bool(is_private) | |
| 37 | + | else: | |
| 38 | + | return not bool(is_private) | |
| 38 | 39 | ||
| 39 | 40 | ||
| 40 | 41 | @validator | |
The check that tells the two apart
fail→pass·tests/test_ip_address.py::test_returns_valid_on_private_ipv4_address[1.1.1.1-False]
Check file tests/test_ip_address.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itd46cd586bdd6b9946d5d421f009794a25650f72e
Broken version dated2024-05-07
Modulevalidators.ip_address
Units changed_check_private_ip
Fingerprint2ff85b21a7bd416f
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in python-validators/validators
- 2025-03-28email
- 2024-04-18domain
- 2023-09-17fix: Valid URLs failing validation - query and fragment parts (#297)