From: Aarni Koskela Date: Fri, 22 Jan 2016 18:42:03 +0000 (+0200) Subject: plural: don't ignore possible rules in `other` category X-Git-Tag: 2.3.1~18^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc8f19ea1de43850c1824e405007d7be5159548e;p=thirdparty%2Fbabel.git plural: don't ignore possible rules in `other` category --- diff --git a/babel/plural.py b/babel/plural.py index b5ce9ba6..63e395ba 100644 --- a/babel/plural.py +++ b/babel/plural.py @@ -86,14 +86,14 @@ class PluralRule(object): found = set() self.abstract = [] for key, expr in sorted(list(rules)): - if key == 'other': - continue if key not in _plural_tags: raise ValueError('unknown tag %r' % key) elif key in found: raise ValueError('tag %r defined twice' % key) found.add(key) - self.abstract.append((key, _Parser(expr).ast)) + ast = _Parser(expr).ast + if ast: + self.abstract.append((key, ast)) def __repr__(self): rules = self.rules @@ -388,6 +388,11 @@ class _Parser(object): def __init__(self, string): self.tokens = tokenize_rule(string) + if not self.tokens: + # If the pattern is only samples, it's entirely possible + # no stream of tokens whatsoever is generated. + self.ast = None + return self.ast = self.condition() if self.tokens: raise RuleError('Expected end of rule, got %r' %