From 2141bdb944084b7bcf98648c47a50e5f96739922 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 27 Feb 2021 16:55:17 +0100 Subject: [PATCH] Fix bug in geoip resolution --- lib/location.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/location.py b/lib/location.py index 69637a4..de9d3ca 100644 --- a/lib/location.py +++ b/lib/location.py @@ -217,6 +217,12 @@ def _geoip(ip_addr): # print(response.subdivisions) city, region, country, ccode, lat, long = response.city.name, response.subdivisions[0].names["en"], response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude _debug_log("[_geoip] %s found" % ip_addr) + except IndexError: + # Tuple error + try: + city, region, country, ccode, lat, long = response.city.name, None, response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude + except IndexError: + return None except (geoip2.errors.AddressNotFoundError): return None return [city, region, country, ccode, lat, long]