[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user