Stop passing the constructed handler function name into an exec()
and instead reference it from the globals() dict.
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