X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Ftelnet.py;h=e483c13deecccbe2bc54f540a361fbf1444e2582;hp=0cc29b8402878f4c35909a8720664932a7627c9f;hb=16fafebe85897b37e1c0f15a6cc11eeaede1c48d;hpb=6375b4be5c22662376bfb1534a5ec77506f6402e diff --git a/mudpy/telnet.py b/mudpy/telnet.py index 0cc29b8..e483c13 100644 --- a/mudpy/telnet.py +++ b/mudpy/telnet.py @@ -1,8 +1,8 @@ """Telnet functions and constants for the mudpy engine.""" -# Copyright (c) 2004-2018 Jeremy Stanley . Permission -# to use, copy, modify, and distribute this software is granted under -# terms provided in the LICENSE file distributed with this software. +# 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. import mudpy @@ -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):