Merge "Handle unhandled exception in dnsutils.py for py3"

This commit is contained in:
Jenkins 2015-07-10 16:06:44 +00:00 committed by Gerrit Code Review
commit 59fe84d00c
2 changed files with 9 additions and 1 deletions

View File

@ -123,6 +123,14 @@ class SerializationMiddleware(DNSMiddleware):
response = self._build_error_response()
except Exception:
LOG.exception(_LE("Unknown exception deserializing packet "
"from %(host)s %(port)d") %
{'host': request['addr'][0],
'port': request['addr'][1]})
response = self._build_error_response()
else:
# Hand the Deserialized packet onto the Application
for response in self.application(message):

View File

@ -39,7 +39,7 @@ class MdnsServiceTest(MdnsTestCase):
@mock.patch.object(dns.message, 'make_query')
def test_handle_empty_payload(self, query_mock):
self.service._dns_handle(self.addr, None)
self.service._dns_handle(self.addr, ' '.encode('utf-8'))
query_mock.assert_called_once_with('unknown', dns.rdatatype.A)
@mock.patch.object(socket.socket, 'sendto', new_callable=mock.MagicMock)