Commit 639b3ef5 by William Tisäter

Fix _get_record, only return None from record_by_addr

parent a95b41f8
...@@ -324,7 +324,7 @@ class GeoIP(GeoIPBase): ...@@ -324,7 +324,7 @@ class GeoIP(GeoIPBase):
""" """
seek_country = self._seek_country(ipnum) seek_country = self._seek_country(ipnum)
if seek_country == self._databaseSegments: if seek_country == self._databaseSegments:
return None return {}
read_length = (2 * self._recordLength - 1) * self._databaseSegments read_length = (2 * self._recordLength - 1) * self._databaseSegments
self._lock.acquire() self._lock.acquire()
...@@ -572,7 +572,11 @@ class GeoIP(GeoIPBase): ...@@ -572,7 +572,11 @@ class GeoIP(GeoIPBase):
message = 'Invalid database type, expected City' message = 'Invalid database type, expected City'
raise GeoIPError(message) raise GeoIPError(message)
return self._get_record(ipnum) rec = self._get_record(ipnum)
if not rec:
return None
return rec
except ValueError: except ValueError:
raise GeoIPError('Failed to lookup address %s' % addr) raise GeoIPError('Failed to lookup address %s' % addr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment