From 6a95540bf56811cd1d9e131b76abea42a680b792 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 13 Sep 2024 16:46:34 +0200 Subject: [PATCH] fix: nicer error message on bench execute --- frappe/commands/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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