From 5dc37da885737b547e7320d1f5a1343296bb6e82 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Wed, 18 Dec 2019 14:16:56 +0000 Subject: [PATCH] [IMP] tools: Don't shadow ZeroDivisionError with ValueError in safe_eval If a division by zero occurs, I expect a ZeroDivisionError instead of a TypeError. --- odoo/tools/safe_eval.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/tools/safe_eval.py b/odoo/tools/safe_eval.py index 060514fbf91..37b6e4b425f 100644 --- a/odoo/tools/safe_eval.py +++ b/odoo/tools/safe_eval.py @@ -366,6 +366,8 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal raise except odoo.exceptions.MissingError: raise + except ZeroDivisionError: + raise except Exception as e: raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr)) def test_python_expr(expr, mode="eval"):