diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 81505e86a1..84a937db33 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -280,10 +280,12 @@ def execute(context, method, args=None, kwargs=None, profile=False): ret = frappe.get_attr(method)(*args, **kwargs) except Exception: # eval is safe here because input is from console - ret = eval(method, globals(), locals()) # nosemgrep + code = compile(method, "", "eval") + ret = eval(code, globals(), locals()) # nosemgrep if callable(ret): suffix = "(*args, **kwargs)" - ret = eval(method + suffix, globals(), locals()) # nosemgrep + code = compile(method + suffix, "", "eval") + ret = eval(code, globals(), locals()) # nosemgrep if profile: import pstats