[FIX] b_v_inheritance_extension: fix parsing of 'update' operation

This fixes an error we could get if the attribute of the inherited tag
has some extra carriage returns.

Exception raised: SyntaxError: unexpected EOF while parsing
pull/2494/head
Sébastien Alix 2022-10-24 12:47:54 +02:00 committed by Enric Tobella
parent 45e79144af
commit a227c1e942
1 changed files with 2 additions and 1 deletions

View File

@ -112,7 +112,8 @@ class IrUiView(models.Model):
for spec in specs:
attr_name = spec.get("name")
# Parse ast from both node and spec
source_ast = ast.parse(node.get(attr_name) or "{}", mode="eval").body
node_attr = (node.get(attr_name) or "{}").strip()
source_ast = ast.parse(node_attr, mode="eval").body
update_ast = ast.parse(spec.text.strip(), mode="eval").body
if not isinstance(source_ast, ast.Dict):
raise TypeError(f"Attribute `{attr_name}` is not a dict")