1
0
mirror of https://github.com/django/django.git synced 2025-06-05 19:49:13 +00:00

[5.1.x] Simplified GeoIP2._query() when passing IPv4Address()/IPv6Address() instances.

There is no need to call validate_ipv46_address() for
ipaddress.IPv4Address()/ipaddress.IPv6Address() instances since this
relies on trying to create these kind objects from strings, so they will
always be valid.

Backport of 0cabed9efa2c7abd1693860069f20ec5db41fcd8 from main.
This commit is contained in:
Mariusz Felisiak 2025-01-14 22:48:58 +01:00 committed by Natalia
parent c81669cb54
commit 1c29ab24df

View File

@ -153,6 +153,7 @@ class GeoIP2:
if require_city and not self.is_city:
raise GeoIP2Exception(f"Invalid GeoIP city data file: {self._path}")
if isinstance(query, str):
try:
validate_ipv46_address(query)
except ValidationError: