Commit 51997a7a by Jiri Techet

Do not use except: without specifying exception

except: catches all exceptions, including exceptions like unbound variables etc.
Instead specify only exceptions which can be thrown if database is corrupted
(array overflow, decode() failure). read() and seek() shouldn't throw an exception
if the file is open and accessible so these two exceptions seem to be enough.
parent 59e1bc09
...@@ -243,7 +243,7 @@ class GeoIP(object): ...@@ -243,7 +243,7 @@ class GeoIP(object):
if x[0] >= self._databaseSegments: if x[0] >= self._databaseSegments:
return x[0] return x[0]
offset = x[0] offset = x[0]
except: except (IndexError, UnicodeDecodeError):
pass pass
raise GeoIPError('Corrupt database') raise GeoIPError('Corrupt database')
......
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