From bc9c8c3dcc4666af951d2fa80a3abdf42184d6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 4 Feb 2016 20:39:50 +0100 Subject: [PATCH] Raise an exception on empty packets (geoip Python class) --- tests/iptogeo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/iptogeo.py b/tests/iptogeo.py index ae3cbf4..847f8a9 100644 --- a/tests/iptogeo.py +++ b/tests/iptogeo.py @@ -75,11 +75,12 @@ class IPToGeo(object): try: self._socket.send(packet) except IOError, e: - # Give another chance (we may have been disconnected due to timeout + # Give another chance (we may have been disconnected due to timeout) self._create_socket() self._socket.send(packet) packet = self._socket.recv(IPToGeo.PACKET_SIZE) - + if not packet: + raise IPToGeoException('Error, empty packet') (ip, country_code) = self._check_request(packet) if country_code: # convert to string