From: Jeremy Stanley Date: Tue, 24 Dec 2019 22:37:18 +0000 (+0000) Subject: Remove exec() from handle_user_input() function X-Git-Tag: 0.1.0~18 X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=commitdiff_plain;h=40fb678ab8ea5e35f06826bda8f484053dd831b1;ds=sidebyside Remove exec() from handle_user_input() function Stop passing the constructed handler function name into an exec() and instead reference it from the globals() dict. --- diff --git a/mudpy/misc.py b/mudpy/misc.py index fca279a..24443dd 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -1685,9 +1685,9 @@ def handle_user_input(user): user.send("", add_prompt=False, prepend_padding=False) # check to make sure the state is expected, then call that handler - if "handler_" + user.state in globals(): - exec("handler_" + user.state + "(user)") - else: + try: + globals()["handler_" + user.state](user) + except KeyError: generic_menu_handler(user) # since we got input, flag that the menu/prompt needs to be redisplayed