Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require args when creating a CallExpression #42

Merged
merged 1 commit into from
Feb 5, 2018

Conversation

zbraniecki
Copy link
Collaborator

While working on https://bugzilla.mozilla.org/show_bug.cgi?id=1424682 I noticed that it's not possible to create a CallExpression without passing args, even if empty.

I think it'll be pretty common in migration code to want to call FTL.CallExpression("PLATFORM") etc.

@flodolo
Copy link
Contributor

flodolo commented Feb 4, 2018

I'm not sure if this is related to this patch, but when running a dry-run on all locales, I see failures on some of them (old ones, like csb, ve, ss).

The error happens on the PLATFORM() migration

Running migration bug_1424682_preferences_chrome for csb
WARNING:migrate:Missing plural categories for csb
INFO:migrate:Localization file browser/browser/preferences/preferences.ftl does not exist and it will be created
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/github/python-fluent/fluent/migrate/context.py", line 363, in serialize_changeset
    for path, snapshot in self.merge_changeset(changeset)
  File "/Users/flodolo/github/python-fluent/fluent/migrate/context.py", line 363, in <dictcomp>
    for path, snapshot in self.merge_changeset(changeset)
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 33, in serialize
    parts.append(self.serialize_entry(entry, state))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 41, in serialize_entry
    return serialize_message(entry)
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 104, in serialize_message
    parts.append(serialize_attribute(attribute))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 114, in serialize_attribute
    indent(serialize_value(attribute.value))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 122, in serialize_value
    content = serialize_pattern(pattern)
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 129, in serialize_pattern
    for elem in pattern.elements
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 137, in serialize_element
    return serialize_placeable(element)
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 155, in serialize_placeable
    return "{{ {}}}".format(serialize_select_expression(expr))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 209, in serialize_select_expression
    parts.append(serialize_variant(variant))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 220, in serialize_variant
    indent(serialize_value(variant.value))
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 119, in serialize_value
    multi = contain_new_line(pattern.elements)
  File "/Users/flodolo/github/python-fluent/fluent/syntax/serializer.py", line 14, in contain_new_line
    if isinstance(elem, ast.TextElement) and "\n" in elem.value
TypeError: argument of type 'NoneType' is not iterable

@Pike
Copy link
Contributor

Pike commented Feb 4, 2018

csb doesn't have prefWindow.title. There seems to be a problem propagating missing strings up to missing messages.

I propose that in this case, we shouldn't try to resurrect the message with partial platform support.

Different bug, though.

Copy link
Contributor

@stasm stasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Please land a corresponding change to fluent-syntax in JS to make sure args is always an array.

super(CallExpression, self).__init__(**kwargs)
self.callee = callee
self.args = args
self.args = args if args is not None else []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written more succinctly as args or []. It is also the convention used by other classes in this file.

@stasm
Copy link
Contributor

stasm commented Feb 5, 2018

csb doesn't have prefWindow.title. There seems to be a problem propagating missing strings up to missing messages.

There's bug 1321271 about supporting partial migrations. I think it's a big feature which is out of the scope of the upcoming L20n milestone. I submitted #44 to prevent the error @flodolo ran into by explicitly never allowing partial migrations for now.

@zbraniecki zbraniecki merged commit 01be516 into projectfluent:master Feb 5, 2018
@stasm stasm added this to the python-fluent 0.6.1 milestone Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants