appliedsec / pygeoip

DEPRECATED: Pure Python API for Maxmind's binary GeoIP databases
https://github.com/appliedsec/pygeoip
GNU Lesser General Public License v3.0
481 stars 111 forks source link

pygeoip._get_record returns None when country is not found, shoul return empty dict. #27

Closed adcaes closed 11 years ago

adcaes commented 11 years ago

Functions that call _get_record expect a dict as return value, if None is returned an exception is raised. The fix is just replacing "return None" by "return {}" in _init._get_record:321.

Stack trace of the error:

File "/pygeoip/init.py", line 430, in country_code_by_addr return self.region_by_addr(addr)['country_code']

File "/pygeoip/init.py", line 588, in region_by_addr return self._get_region(ipnum)

File "/pygeoip/init.py", line 296, in _get_region country_code = rec['country_code'] if 'country_code' in rec else ''

TypeError: argument of type 'NoneType' is not iterable