Closed
Bug 1441799
Opened 6 years ago
Closed 6 years ago
Migration error: AttributeError: 'NumberExpression' object has no attribute 'name'
Categories
(L20n :: Python Library, defect)
L20n
Python Library
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: flod, Assigned: stas)
References
Details
Attachments
(1 file)
I'm running bug_1435912_preferences_general_xul on Italian, and it works as expected. Once I've run it, it's impossible to run any other migration, I end up with this error AttributeError: 'NumberExpression' object has no attribute 'name' It fails on use-current-pages = .label = { $tabCount -> [1] Usa la pagina corrente *[other] Usa le pagine correnti } .accesskey = U
Reporter | ||
Comment 1•6 years ago
|
||
I think the exception is generated here https://github.com/projectfluent/python-fluent/blob/master/fluent/syntax/ast.py#L110 Full traceback Traceback (most recent call last): File "/Users/flodolo/mozilla/mercurial/mozilla-unified/third_party/python/fluent/tools/migrate/migrate-l10n.py", line 120, in <module> dry_run=args.dry_run File "/Users/flodolo/mozilla/mercurial/mozilla-unified/third_party/python/fluent/tools/migrate/migrate-l10n.py", line 53, in main snapshot = ctx.serialize_changeset(changeset['changes']) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/migrate/context.py", line 389, in serialize_changeset changeset, known_translations File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/migrate/context.py", line 387, in <dictcomp> path: self.fluent_serializer.serialize(snapshot) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/migrate/context.py", line 369, in merge_changeset if self.messages_equal(current, snapshot): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/migrate/context.py", line 280, in messages_equal if not msg1.equals(msg2): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 120, in equals if not scalars_equal(elem1, elem2, ignored_fields): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 39, in scalars_equal return node1.equals(node2, ignored_fields) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 123, in equals elif not scalars_equal(field1, field2, ignored_fields): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 39, in scalars_equal return node1.equals(node2, ignored_fields) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 120, in equals if not scalars_equal(elem1, elem2, ignored_fields): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 39, in scalars_equal return node1.equals(node2, ignored_fields) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 123, in equals elif not scalars_equal(field1, field2, ignored_fields): File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 39, in scalars_equal return node1.equals(node2, ignored_fields) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 116, in equals field1 = sorted(field1, key=sorting) File "/Users/flodolo/mozilla/mercurial/python-fluent/fluent/syntax/ast.py", line 111, in <lambda> 'variants': lambda elem: elem.key.name, AttributeError: 'NumberExpression' object has no attribute 'name'
Reporter | ||
Comment 2•6 years ago
|
||
@stas Any chance you can take a look? I'm not sure if I'm overlooking anything, but it seems like a quick fix for someone who has the full picture of python-fluent. Not sure if the check should ignore .name for NumberExpression, or NumberExpression should have a .name
Flags: needinfo?(stas)
Assignee | ||
Comment 3•6 years ago
|
||
I see what's going on. BaseNode.equals sorts order-agnostic fields such as attributes and variants in order to ensure the equality comparison works correctly even if the order of the elements differs. The code used to assume all variant keys were VariantName instances. We need to support numbers as keys as well.
Assignee: nobody → stas
Status: NEW → ASSIGNED
Flags: needinfo?(stas)
Assignee | ||
Comment 4•6 years ago
|
||
Fixed in https://github.com/projectfluent/python-fluent/commit/650aba48c8bfe54f70679149dcffbeca48e302f9.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•