From 40fb678ab8ea5e35f06826bda8f484053dd831b1 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 24 Dec 2019 22:37:18 +0000 Subject: [PATCH] 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. --- mudpy/misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.11.0