From f3212ccede02fe9cf5552d6fedc8acca41bff439 Mon Sep 17 00:00:00 2001 From: "Alex (roal)" Date: Tue, 27 Jun 2023 09:55:22 +0000 Subject: [PATCH] [FIX] tools: fix TypeError in literal_eval A TypeError is thrown when an AST node is passed to `literal_eval` because a string is expected and the object has no len(). Check the type of the expression and make sure it's a string before calling len() on it. closes odoo/odoo#126874 X-original-commit: 28b5cbb33a99cdca00daa35e5ae598cc8d4b2dae Signed-off-by: Vranckx Florian (flvr) --- odoo/tools/_monkeypatches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/tools/_monkeypatches.py b/odoo/tools/_monkeypatches.py index f6e6eb4b5b7..91aa3f9f47d 100644 --- a/odoo/tools/_monkeypatches.py +++ b/odoo/tools/_monkeypatches.py @@ -44,7 +44,7 @@ def literal_eval(expr): else: _logger.error("ODOO_LIMIT_LITEVAL_BUFFER has to be an integer, defaulting to 100KiB") - if len(expr) > buffer_size: + if isinstance(expr, str) and len(expr) > buffer_size: raise ValueError("expression can't exceed buffer limit") return orig_literal_eval(expr)