[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) <flvr@odoo.com>
This commit is contained in:
Alex (roal)
2023-07-03 21:56:06 +02:00
parent 0ae2b9a3f2
commit f3212ccede
+1 -1
View File
@@ -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)