From ae979e852d52e3da493f6e19a91e6fe0879ff5ff Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 23 Jan 2019 21:15:14 +0100 Subject: [PATCH] Catch keyerrors in amp box, as per #1306 --- evennia/server/portal/amp.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/evennia/server/portal/amp.py b/evennia/server/portal/amp.py index 71a1bcba91..1e0817b4ab 100644 --- a/evennia/server/portal/amp.py +++ b/evennia/server/portal/amp.py @@ -279,13 +279,19 @@ class AMPMultiConnectionProtocol(amp.AMP): if data[-2:] != NULNUL: # an incomplete AMP box means more batches are forthcoming. self.multibatches += 1 - super(AMPMultiConnectionProtocol, self).dataReceived(data) + try: + super(AMPMultiConnectionProtocol, self).dataReceived(data) + except KeyError: + _LOGGER.trace("Discarded incoming partial data: {}".format(to_str(data))) elif self.multibatches: # invalid AMP, but we have a pending multi-batch that is not yet complete if data[-2:] == NULNUL: # end of existing multibatch self.multibatches = max(0, self.multibatches - 1) - super(AMPMultiConnectionProtocol, self).dataReceived(data) + try: + super(AMPMultiConnectionProtocol, self).dataReceived(data) + except KeyError: + _LOGGER.trace("Discarded incoming multi-batch data:".format(to_str(data))) else: # not an AMP communication, return warning self.transport.write(_HTTP_WARNING)