Skip to content

Commit ad307c2

Browse files
committed
[IMP] tools: separate compilation/assertion code object
Adapt util. Community PR: odoo/odoo#217284
1 parent b977faa commit ad307c2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/misc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,12 @@ def safe_eval(expr, context=None):
543543
assert isinstance(expr, (str, bytes))
544544
assert isinstance(context, SelfPrintEvalContext)
545545

546-
c = _safe_eval_mod.test_expr(expr, _safe_eval_mod._SAFE_OPCODES, mode="eval", filename=None)
546+
if version_gte("saas~18.5"):
547+
c = _safe_eval_mod.compile_codeobj(expr, filename=None, mode="eval")
548+
_safe_eval_mod.assert_valid_codeobj(_safe_eval_mod._SAFE_OPCODES, c, expr)
549+
else:
550+
c = _safe_eval_mod.test_expr(expr, _safe_eval_mod._SAFE_OPCODES, mode="eval", filename=None)
551+
547552
context["__builtins__"] = dict(_safe_eval_mod._BUILTINS)
548553
try:
549554
return _safe_eval_mod.unsafe_eval(c, context, None)

0 commit comments

Comments
 (0)