Skip to content

Commit 2ce4f01

Browse files
committed
[FIX] base/17.0: skip empty attrs
Avoid error if `attrs` is already empty. ``` File "/tmp/tmpxxqc0zp2/migrations/base/17.0.1.3/attr_domains2expr.py", line 221, in fix_elem ast_attrs = ast_parse(attrs_val) File "/tmp/tmpxxqc0zp2/migrations/base/17.0.1.3/attr_domains2expr.py", line 333, in ast_parse return ast.parse(val.strip(), mode="eval").body File "/usr/lib/python3.10/ast.py", line 50, in parse return compile(source, filename, mode, flags, File "<unknown>", line 0 SyntaxError: invalid syntax ``` ``` (Pdb) tostring(elem) b'<field name="origin" attrs=""/>\n ' ``` closes #79 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent b0ce3bf commit 2ce4f01

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/base/17.0.1.3/attr_domains2expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def fix_elem(cr, model, elem, comb_arch):
216216
etree.tostring(telem).decode(),
217217
)
218218

219-
if "attrs" in elem.attrib:
219+
if elem.get("attrs"):
220220
attrs_val = elem.get("attrs")
221221
ast_attrs = ast_parse(attrs_val)
222222
if isinstance(ast_attrs, ast.Dict):
@@ -232,7 +232,7 @@ def fix_elem(cr, model, elem, comb_arch):
232232
attrs_val,
233233
etree.tostring(elem).decode(),
234234
)
235-
elem.attrib.pop("attrs")
235+
elem.attrib.pop("attrs", "")
236236

237237
for mod in MODS:
238238
if mod not in elem.attrib and mod not in attrs:

0 commit comments

Comments
 (0)