X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Ftelnet.py;h=e483c13deecccbe2bc54f540a361fbf1444e2582;hp=0ce9aec21958782ae98ffba8dcadd58215892609;hb=16fafebe85897b37e1c0f15a6cc11eeaede1c48d;hpb=cd63085011ec98a8949fca48217e4efad5558908 diff --git a/mudpy/telnet.py b/mudpy/telnet.py index 0ce9aec..e483c13 100644 --- a/mudpy/telnet.py +++ b/mudpy/telnet.py @@ -1,6 +1,6 @@ """Telnet functions and constants for the mudpy engine.""" -# Copyright (c) 2004-2018 mudpy authors. Permission to use, copy, +# Copyright (c) 2004-2019 mudpy authors. Permission to use, copy, # modify, and distribute this software is granted under terms # provided in the LICENSE file distributed with this software. @@ -97,7 +97,20 @@ def telnet_proto(*arguments): def translate_action(*command): """Convert a Telnet command sequence into text suitable for logging.""" - return "%s %s" % (command_names[command[0]], option_names[command[1]]) + try: + command_name = command_names[command[0]] + except KeyError: + # This should never happen since we filter unknown commands from + # the input queue, but added here for completeness since logging + # should never crash the process + command_name = str(command[0]) + try: + option_name = option_names[command[1]] + except KeyError: + # This can happen for any of the myriad of Telnet options missing + # from the option_names dict + option_name = str(command[1]) + return "%s %s" % (command_name, option_name) def send_command(user, *command):