Skip to content

Commit bbaaaaf

Browse files
committed
[IMP] tools: separate compilation/assertion code object
Adapt util. Community PR: odoo/odoo#217284 closes #293 Related: odoo/odoo#217284 Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
1 parent f1dd8f8 commit bbaaaaf

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
@@ -545,7 +545,12 @@ def safe_eval(expr, context=None):
545545
assert isinstance(expr, (str, bytes))
546546
assert isinstance(context, SelfPrintEvalContext)
547547

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

0 commit comments

Comments
 (0)